about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-30 00:41:03 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-30 00:41:11 -0700
commita479f0d0837be5fec7e92ef806cc50b9c17ed50c (patch)
treed0a45509c4fc3706b8f5733eb76c342a0f4e65e3
parentc970190021a0aeb2b73558a9095f63a774f439ba (diff)
downloadmu-a479f0d0837be5fec7e92ef806cc50b9c17ed50c.tar.gz
.
Open question fixed.
-rw-r--r--103glyph.subx8
-rw-r--r--apps/ex14.mu2
2 files changed, 5 insertions, 5 deletions
diff --git a/103glyph.subx b/103glyph.subx
index 61035f22..f10ac871 100644
--- a/103glyph.subx
+++ b/103glyph.subx
@@ -84,7 +84,7 @@ draw-code-point-on-screen-buffer:  # buffer: (addr byte), c: code-point, x: int,
     8b/-> *(ebp+0xc) 6/r32/esi
     # if (c >= 4352) return  # unicode planes supported: latin, greek, cyrillic, armenian, hebrew, arabic, syriac, thaana, n'ko, indian (iscii), sinhala, thai, lao, tibetan, myanmar, georgian
                              # next few to support: CJK, ethiopic, cherokee, ...
-    81 7/subop/compare %esi 0x1100/imm32
+    81 7/subop/compare %esi 0x1100/imm32=4352
     0f 8d/jump-if->= $draw-code-point-on-screen-buffer:end/disp32
     # var letter-bitmap/esi = font[c]
     69/multiply %esi 0x21/imm32/glyph-size 6/r32/esi
@@ -208,14 +208,14 @@ draw-wide-code-point-on-screen-buffer:  # buffer: (addr byte), letter-bitmap: (a
       39/compare %edx 7/r32/edi
       0f 8d/jump-if->= break/disp32
       # var row-bitmap/ebx: byte = *letter-bitmap
-      8a/byte-> *(esi+1) 3/r32/BL
+      8a/byte-> *esi 3/r32/BL
       # ecx = x
       8b/-> *(ebp+0x10) 1/r32/ecx
       # first half-row
       (draw-run-of-pixels-from-glyph *(ebp+8) %ebx %ecx %edx *(ebp+0x18) *(ebp+0x1c) *(ebp+0x20) *(ebp+0x24))
       # second half-row
-      8a/byte-> *esi 3/r32/BL
-      49/increment-ecx
+      8a/byte-> *(esi+1) 3/r32/BL
+      41/increment-ecx
       (draw-run-of-pixels-from-glyph *(ebp+8) %ebx %ecx %edx *(ebp+0x18) *(ebp+0x1c) *(ebp+0x20) *(ebp+0x24))
       # ++y
       42/increment-edx
diff --git a/apps/ex14.mu b/apps/ex14.mu
index 600aded5..4a2d5dd7 100644
--- a/apps/ex14.mu
+++ b/apps/ex14.mu
@@ -23,5 +23,5 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
   var text-storage: (stream byte 0x200)
   var text/esi: (addr stream byte) <- address text-storage
   load-sectors data-disk, 0/lba, 1/num-sectors, text
-  var dummy/eax: int <- draw-stream-rightward screen, text, 1/x 0x80/xmax 0/y, 0xa/fg, 0/bg
+  var dummy/eax: int <- draw-stream-rightward screen, text, 0/x 0x80/xmax 0/y, 0xa/fg, 0/bg
 }
e>
                                                 





































































                                                                      











                                                                




























                                                                      
package main

import (
	"fmt"
	"io/ioutil"
	"os"

	"framagit.org/andinus/cetus/pkg/apod"
	"framagit.org/andinus/cetus/pkg/background"
	"framagit.org/andinus/indus/notification"
)

func execAPOD() {
	// reqInfo holds all the parameters that needs to be sent with
	// the request. GetJson() will pack apiKey & date in params
	// map before sending it to another function. Adding params
	// here will not change the behaviour of the function, changes
	// have to be made in GetJson() too.
	reqInfo := make(map[string]string)
	reqInfo["api"] = string(*apodAPI)
	reqInfo["apiKey"] = string(*apodKey)
	reqInfo["date"] = string(*apodDate)

	if *apodRand {
		reqInfo["date"] = apod.RandDate()
	}

	cacheDir := fmt.Sprintf("%s/%s", getCacheDir(), "apod")
	os.MkdirAll(cacheDir, os.ModePerm)

	// Check if the file is available locally, if it is then don't
	// download it again and get it from disk
	var body string
	file := fmt.Sprintf("%s/%s", cacheDir, reqInfo["date"])
	if _, err := os.Stat(file); err == nil {
		data, err := ioutil.ReadFile(file)
		chkErr(err)
		body = string(data)
	} else if os.IsNotExist(err) {
		body, err = apod.GetJson(reqInfo)
		chkErr(err)

		// Write body to the cache so that it can be read
		// later
		err = ioutil.WriteFile(file, []byte(body), 0644)
		chkErr(err)
	} else {
		chkErr(err)
	}

	if *apodDump {
		fmt.Printf(body)
		os.Exit(0)
	}

	res := apod.Res{}
	err := apod.UnmarshalJson(&res, body)
	chkErr(err)

	// res.Msg will be returned when there is error on user input
	// or the api server.
	if len(res.Msg) != 0 {
		fmt.Printf("Message: %s", res.Msg)
		os.Exit(1)
	}

	// If path-only is passed then it will only print the path,
	// even if quiet is passed. If the user wants the program to
	// be quiet then path-only shouldn't be passed. If path-only
	// is not passed & quiet is also not passed then print the
	// response.
	//
	// Path is only printed when the media type is an image
	// because res.HDURL is empty on non image media type.
	if *apodPathOnly {
		fmt.Println(res.HDURL)
	} else if !*apodQuiet {
		apod.Print(res)
	}

	// Send a desktop notification if notify flag was passed
	if *apodNotify {
		n := notification.Notif{}
		n.Title = res.Title
		n.Message = fmt.Sprintf("%s\n\n%s",
			res.Date,
			res.Explanation)

		err = n.Notify()
		chkErr(err)
	}

	// Proceed only if the command was set because if it was fetch
	// then it's already finished & should exit now.
	if os.Args[1] == "fetch" {
		os.Exit(0)
	}

	// Try to set background only if the media type is an image.
	// First it downloads the image to the cache directory and
	// then tries to set it with feh. If the download fails then
	// it exits with a non-zero exit code.
	if res.MediaType != "image" {
		os.Exit(0)
	}
	imgCacheDir := fmt.Sprintf("%s/%s", cacheDir, "background")
	os.MkdirAll(imgCacheDir, os.ModePerm)
	imgFile := fmt.Sprintf("%s/%s", imgCacheDir, reqInfo["date"])

	// Check if the file is available locally, if it is
	// then don't download it again and set it from disk
	if _, err := os.Stat(imgFile); os.IsNotExist(err) {
		err = background.Download(imgFile, res.HDURL)
		chkErr(err)
	} else {
		chkErr(err)
	}

	err = background.Set(imgFile)
	chkErr(err)
}