gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 72a838fd62144c8db2e1113beec4c4929f9b21d8 parent 6ef2329db0130911445527cd50dca1b70cf2288f Author: Toxa <untoxa@mail.ru> Date: Mon, 21 Dec 2020 20:21:20 +0300 input.s now takes into account loaded font Diffstat:
| M | gbdk-lib/examples/gb/rpn/rpn.c | 4 | ---- |
| M | gbdk-lib/libc/gb/f_ibm_sh.s | 66 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- |
| M | gbdk-lib/libc/gb/input.s | 76 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ |
3 files changed, 133 insertions(+), 13 deletions(-)
diff --git a/gbdk-lib/examples/gb/rpn/rpn.c b/gbdk-lib/examples/gb/rpn/rpn.c @@ -1,4 +1,3 @@ -#include <gb/font.h> #include <stdio.h> #include <ctype.h> @@ -68,9 +67,6 @@ void main(void) BYTE type; WORD op2; - font_init(); - font_load(font_ibm_fixed); - puts("RPN Calculator"); sp = 0; pos = 0; diff --git a/gbdk-lib/libc/gb/f_ibm_sh.s b/gbdk-lib/libc/gb/f_ibm_sh.s @@ -14,10 +14,10 @@ _font_load_ibm:: ; Banked ; 898 bytes giving ' '-'0'-'@'-'A'-'Z'-'???'-'a'-'z'-127 _font_ibm:: .byte 1+4 ; 128 character encoding - .byte 128-32 ; Tiles required + .byte 128-32+6 ; Tiles required - .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; All map to space - .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,97 ; All map to space + .byte 0,0,0,0,0,0,0,0,0,0,0,0,98,99,100,101 .byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ; 0x20 .byte 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 .byte 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47 ; 0x40 @@ -121,3 +121,63 @@ _font_ibm:: .byte 0x70,0x18,0x18,0x0C,0x18,0x18,0x70,0x00 .byte 0x00,0x60,0xF2,0x9E,0x0C,0x00,0x00,0x00 .byte 0x10,0x10,0x28,0x28,0x44,0x44,0x82,0xFE + +; Character: ? (0E) + .db 0b00000000 ; + .db 0b00000000 ; + .db 0b00000000 ; + .db 0b11111111 ; oooooooo + .db 0b11111111 ; oooooooo + .db 0b11111111 ; oooooooo + .db 0b00000000 ; + .db 0b00000000 ; + +; Character: ? (0F) + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + +; Character: ? (1C) + .db 0b00000000 ; + .db 0b00000000 ; + .db 0b00000000 ; + .db 0b00011111 ; ooooo + .db 0b00011111 ; ooooo + .db 0b00011111 ; ooooo + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + +; Character: ? (1D) + .db 0b00000000 ; + .db 0b00000000 ; + .db 0b00000000 ; + .db 0b11111100 ; oooooo + .db 0b11111100 ; oooooo + .db 0b11111100 ; oooooo + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + +; Character: ? (1E) + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + .db 0b00011111 ; ooooo + .db 0b00011111 ; ooooo + .db 0b00011111 ; ooooo + .db 0b00000000 ; + .db 0b00000000 ; + +; Character: ? (1F) + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + .db 0b00011100 ; ooo + .db 0b11111100 ; oooooo + .db 0b11111100 ; oooooo + .db 0b11111100 ; oooooo + .db 0b00000000 ; + .db 0b00000000 ; diff --git a/gbdk-lib/libc/gb/input.s b/gbdk-lib/libc/gb/input.s @@ -89,13 +89,15 @@ ;; Initialize window LD BC,#.frame_tiles - LD DE,#0x0000 ; Place image at (0x00,0x00) tiles - LD HL,#0x140A ; Image size is 0x14 x 0x0A tiles - CALL .set_xy_wtt + LD DE,#0x140A ; 0x140A + LD HL,#0 + CALL set_recoded_win_tiles + LD BC,#.kbdtable - LD DE,#0x0202 ; Place image at (0x02,0x02) tiles - LD HL,#.KBDSIZE ; Image size is 0x10 x 0x06 tiles - CALL .set_xy_wtt + LD DE,#.KBDSIZE + LD HL,#(0x20 * 2 + 2) ; X=2, Y=2 + CALL set_recoded_win_tiles + XOR A LD A,#.MINWNDPOSX LDH (.WX),A @@ -130,6 +132,68 @@ RET +set_recoded_win_tiles:: + LDH A,(.LCDC) + BIT 6,A + JR Z,2$ + LD A,#0x9C + JR 3$ +2$: + LD A,#0x98 +3$: + ADD H + LD H,A + PUSH DE + PUSH HL +4$: + LD A,(BC) + INC BC + PUSH BC + PUSH HL + + LD C,A + LD HL,#(font_current+1) ; font_current+sfont_handle_font + LD A,(HL+) + LD H,(HL) + LD L,A + LD A,(HL+) + AND #3 + CP #2 ; FONT_NOENCODING + JR Z,5$ + INC HL + LD B,#0 + ADD HL,BC + LD C,(HL) +5$: + POP HL + + WAIT_STAT + LD A,C + LD (HL+),A + + POP BC + + DEC D + JR NZ,4$ + + POP HL + POP DE + + LD A,L + ADD #0x20 + LD L,A + ADC H + SUB L + LD H,A + DEC E + + PUSH DE + PUSH HL + JR NZ,4$ + + ADD SP,#4 + RET + .area _CODE ;; Prompt the user for a char and return it in A .get_char:
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.