Kaynağa Gözat

not using hard-coded font for Menu(

Zeda Thomas 4 yıl önce
ebeveyn
işleme
7eadd03e14
5 değiştirilmiş dosya ile 83 ekleme ve 27 silme
  1. 7 0
      docs/grammer2.5.inc
  2. 5 0
      src/01.z80
  3. 31 8
      src/cmd/menu.z80
  4. 7 0
      src/grammer2.5.inc
  5. 33 19
      src/io/menu.z80

+ 7 - 0
docs/grammer2.5.inc

@@ -191,6 +191,13 @@ inputflag       = 0
 ModeFlags2      = 35
 floatmode       = 5
 
+textmode_default  = 0
+textmode_varwidth = 1
+textmode_smallfixed=2
+textmode_Omnicalc = 3
+textmode_OS_small = 4
+textmode_OS_large = 5
+
 
 FS_uint8        = 0
 FS_str          = 3

+ 5 - 0
src/01.z80

@@ -177,6 +177,11 @@ jp_prev_page_call:
   pop hl
   jp prev_page_call
 
+p1_chardim:
+  ld hl,chardim
+  ld (prev_page_call_address),hl
+  jp prev_page_call
+
 verify_package:
 ;A:HL points to the data
 ;BC is the size of the data

+ 31 - 8
src/cmd/menu.z80

@@ -105,16 +105,32 @@ _:
 ;Save the number of elements
   ld (menu_num_items),bc
 
+  push bc
+  call p1_chardim
+  ld a,c
+  ld (font_height),a
+  pop bc
+  ld l,a
+
 ;Now we need to render the menu, but first we'll get the height of the menu in pixels
 ;4+font_height*min(9-int(y/font_height),BC+1
+
+;60/font_height-1 is the initial E value
+  ld a,59
+  ld e,-1
+
+  inc e
+  sub l
+  jr nc,$-2
+
   ld a,(textbox_top)
-  ld e,9
   add a,a
   jr c,cmp_menu_height
+  sla l
   .db $FE
 _:
   dec e
-  sub FONT_HEIGHT*2
+  sub l
   jr nc,-_
 cmp_menu_height:
 ;E is the max height
@@ -148,8 +164,9 @@ _:
   ld (menutopinit),hl
 
 ;now do E*FONT_HEIGHT+4, given that it won't overflow 8 bits
+  ld a,(font_height)
+  ld b,a
   ld a,5
-  ld b,FONT_HEIGHT
 _:
   add a,e
   djnz -_
@@ -163,21 +180,23 @@ _:
 
 menu_entry:
   ;Set the default graphics buffer
-  ld hl,(BufPtr)
-  ld (gbuf_temp),hl
-
+  ; ld hl,(BufPtr)
+  ; ld (gbuf_temp),hl
 
 ;save and set the the font method
   ld a,(textmode)
+  or a
   push af
-  ld a,2
-  ld (textmode),a
   ld hl,(FontPointer)
   push hl
+  jr nz,+_
+  ld a,2
+  ld (textmode),a
   ld hl,FontSet
   ld (FontPointer),hl
   xor a
   ld (font_ptr_page),a
+_:
   ld bc,(textbox_top)
   ld hl,(menuheader_ptr)
 
@@ -216,6 +235,10 @@ fancymenu:
   call p1_ParseNextFullArg
   ld (menu_sel),bc
 
+  call p1_chardim
+  ld a,c
+  ld (font_height),a
+
   ld hl,0
   ld (menutopinit),hl
   ld (menudefault),hl

+ 7 - 0
src/grammer2.5.inc

@@ -191,6 +191,13 @@ inputflag       = 0
 ModeFlags2      = 35
 floatmode       = 5
 
+textmode_default  = 0
+textmode_varwidth = 1
+textmode_smallfixed=2
+textmode_Omnicalc = 3
+textmode_OS_small = 4
+textmode_OS_large = 5
+
 
 FS_uint8        = 0
 FS_str          = 3

+ 33 - 19
src/io/menu.z80

@@ -1,5 +1,5 @@
 #define Text() call p1_PutTokenText
-#define FONT_HEIGHT 6
+font_height = tempword5
 ;#define TEXT_PAD_TOP    ;comment if there is not a row of padding above the text
 ;#define TEXTCOORD_YX      ;define if textcoord is Y then X (TI-OS is Y then X for small font, large font and some custom text routines use the opposite)
 textcoord = textRow
@@ -99,9 +99,9 @@ menuroutine:
   call draw_header
   pop bc
 
-
 ;Before we do too much, let's establish the top-left textbox boundaries.
-  ld a,FONT_HEIGHT+2
+  ld a,(font_height)
+  add a,2
   add a,c
   ld c,a
   ld (textbox_top),bc
@@ -113,7 +113,7 @@ menuroutine:
   ld hl,(menudefault)
   ld (menucur),hl
 
-  ;need t set menu selection to:
+  ;need to set menu selection to:
   ;   (textbox_top-1)+(menucur-menutop)*fontheight
   ;  =(textbox_top-1)+(HL-DE)*fontheight
   ; or a
@@ -160,7 +160,9 @@ menu_render_0:
   ld a,h
   sub b
   ld d,a
-  ld e,FONT_HEIGHT+1
+  ld a,(font_height)
+  ld e,a
+  inc e
   dec d
   push de
   push bc
@@ -214,35 +216,37 @@ menu_render_sub_loop:
   pop bc
   ret c
   ld de,(textcoord)
-  push de
   push bc
+  push de
   Text()
-  pop bc
   pop de
+  ld a,(font_height)
+  ld c,a
 #ifdef TEXTCOORD_YX
-  ld a,FONT_HEIGHT
   add a,d
   ld d,a
   ld a,(textbox_bottom)
+  sub c
 #ifdef TEXT_PAD_TOP
-  sub FONT_HEIGHT+2
+  sub 2
 #else
-  sub FONT_HEIGHT+1
+  dec a
 #endif
   cp d
 #else
-  ld a,FONT_HEIGHT
   add a,e
   ld e,a
   ld a,(textbox_bottom)
+  sub c
 #ifdef TEXT_PAD_TOP
-  sub FONT_HEIGHT+2
+  sub d
 #else
-  sub FONT_HEIGHT+1
+  dec a
 #endif
   cp e
 #endif
   ld (textcoord),de
+  pop bc
   inc bc
   jr nc,menu_render_sub_loop
   ret
@@ -289,7 +293,11 @@ menu_up:
   ld hl,(textbox_top)
   cp l
   jr z,+_
-  sub FONT_HEIGHT
+  ld e,a
+  ld a,(font_height)
+  ld d,a
+  ld a,e
+  sub d
   ld (menuselection),a
   scf
   ret
@@ -311,13 +319,17 @@ menu_down:
   pop hl
   ret c
   ld (menucur),hl
-
+  ld a,(font_height)
+  ld e,a
   ld a,(menuselection)
-  add a,FONT_HEIGHT+FONT_HEIGHT+1
+  add a,e
+  add a,e
+  inc a
   ld hl,(textbox_bottom)
   cp l
   jr nc,+_
-  sub FONT_HEIGHT+1
+  sub e
+  dec a
   ld (menuselection),a
   scf
   ret
@@ -333,7 +345,7 @@ menu_scroll:
 
   push af
   call gettextbox
-  ld h,FONT_HEIGHT
+  ld hl,(font_height-1)
   pop af
 _:
   push af
@@ -424,7 +436,9 @@ draw_header:
   sub b
   ld d,a
   dec b
-  ld e,FONT_HEIGHT+1
+  ld a,(font_height)
+  ld e,a
+  inc e
   rect_Erase()