gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 6fdd1b655f36b5931022e5518a0e26d4bd1371b4 parent 6b9d7586da38f70f306ec53554b3ee602960870c Author: Toxa <untoxa@mail.ru> Date: Mon, 28 Dec 2020 15:46:55 +0300 crash handler now shares default font with stdio, that minimizes rom usage Diffstat:
| M | gbdk-lib/libc/gb/crash_handler.s | 207 | ++++++++++++++++++++++++++++--------------------------------------------------- |
| M | gbdk-lib/libc/gb/f_ibm_sh.s | 9 | --------- |
| M | gbdk-lib/libc/gb/font.s | 7 | ++++++- |
| M | gbdk-support/ChangeLog | 14 | +++++++------- |
4 files changed, 85 insertions(+), 152 deletions(-)
diff --git a/gbdk-lib/libc/gb/crash_handler.s b/gbdk-lib/libc/gb/crash_handler.s @@ -4,6 +4,8 @@ .include "global.s" + .globl _font_ibm + SCRN_X = 160 ; Width of screen in pixels SCRN_Y = 144 ; Height of screen in pixels SCRN_X_B = 20 ; Width of screen in bytes @@ -97,7 +99,7 @@ ___HandleCrash:: .writeAttrRow: xor a ld c, #(SCRN_X_B + 1) - call MemsetSmall + rst #0x28 ; .MemsetSmall ld a, l add a, #(SCRN_VX_B - SCRN_X_B - 1) ld l, a @@ -134,7 +136,7 @@ ___HandleCrash:: ld hl, #vDumpHL ld de, #vCrashHL ld c, #4 - call MemcpySmall + rst #0x30 ; .MemcpySmall ; We're now going to draw the screen, top to bottom ld hl, #vCrashDumpScreen @@ -146,7 +148,7 @@ ___HandleCrash:: ld a, #0x20 ; " " ld (hl+), a ld c, #19 - call MemcpySmall + rst #0x30 ; .MemcpySmall ld a, #0x20 ; " " ld (hl+), a ld a, l @@ -158,16 +160,16 @@ ___HandleCrash:: ; Blank line ld a, #0x20 ; " " ld c, #(SCRN_X_B + 1) - call MemsetSmall + rst #0x28 ; .MemsetSmall ; AF and console model ld l, #<vCrashDumpScreenRow4 ld c, #4 - call MemcpySmall + rst #0x30 ; .MemcpySmall pop bc call .printHexBC ld c, #8 - call MemcpySmall + rst #0x30 ; .MemcpySmall ld a, (__cpu) call .printHexA ld a, #0x20 ; " " @@ -178,11 +180,11 @@ ___HandleCrash:: ; BC and DE ld l, #<vCrashDumpScreenRow5 ld c, #4 - call MemcpySmall + rst #0x30 ; .MemcpySmall pop bc call .printHexBC ld c, #6 - call MemcpySmall + rst #0x30 ; .MemcpySmall pop bc call .printHexBC ld a, #0x20 @@ -196,13 +198,13 @@ ___HandleCrash:: add a, #(SCRN_VX_B - SCRN_X_B - 1) ld l, a ld c, #4 - call MemcpySmall + rst #0x30 ; .MemcpySmall pop bc push bc call .printHexBC ld de, #.viewStr ld c, #7 - call MemcpySmall + rst #0x30 ; .MemcpySmall pop de call .printDump ld de, #.spStr @@ -212,22 +214,22 @@ ___HandleCrash:: ld de, #.hwRegsStrs ld l, #<vCrashDumpScreenRow14 ld c, #6 - call MemcpySmall + rst #0x30 ; .MemcpySmall ld a, (wCrashLCDC) call .printHexA ld c, #4 - call MemcpySmall + rst #0x30 ; .MemcpySmall ldh a, (.KEY1) call .printHexA ld c, #4 - call MemcpySmall + rst #0x30 ; .MemcpySmall ld a, (wCrashIE) call .printHexA ld (hl), #0x20 ; " " ld l, #<vCrashDumpScreenRow15 ld c, #7 - call MemcpySmall + rst #0x30 ; .MemcpySmall .writeBank: ld a, #0x20 ; " " ld (hl+), a @@ -259,20 +261,6 @@ ___HandleCrash:: jr .loop -MemsetSmall: - ld (hl+), a - dec c - jr nz, MemsetSmall - ret - -MemcpySmall: - ld a, (de) - ld (hl+), a - inc de - dec c - jr nz, MemcpySmall - ret - .printHexBC: call .printHexB ld a, c @@ -332,119 +320,68 @@ MemcpySmall: ret loadfont: - ld hl, #.font_data -4$: ld a, (hl+) - ld e, a - ld a, (hl+) - ld d, a - or e - ret Z -1$: - ld c, (hl) - inc hl - bit 7, c - jr Z, 2$ - ld a, (hl+) -3$: - ld (de), a - inc de - ld (de), a + xor a + cpl + ld hl, #0x9000 + ld c, #16 + rst #0x28 ; .MemsetSmall + ld hl, #(0x9000 + ' ' * 16) + ld c, #16 + rst #0x28 ; .MemsetSmall + + ld de, #(_font_ibm + 2 + '0') ; recode table + ld hl, #(0x9000 + '0' * 16) ; destination + push hl + ld c, #(16 * 3) +1$: + ld a, (de) inc de - inc c - jr NZ, 3$ - jr 1$ -2$: - inc c - dec c - jr Z, 4$ -5$: + push de + + swap a + ld l, a + and #0x0f + ld h, a + ld a, l + and #0xf0 + srl h + rra + ld l, a + ld de, #(_font_ibm + 2 + 128) + add hl, de + + ld d, h + ld e, l + + ldhl sp, #2 ld a, (hl+) - ld (de), a - inc de - ld (de), a + ld h, (hl) + ld l, a + + ld b, #8 +2$: + ld a, (de) + cpl inc de - dec c - jr NZ, 5$ - jr 1$ + ld (hl+), a + ld (hl+), a + + dec b + jr nz, 2$ -.font_data: - .dw #0x9000 - .db #-8, #0xff - .db #0 + ld d, h + ld a, l + ldhl sp, #2 + ld (hl+), a + ld (hl), d - .dw #(0x9000 + (0x20 << 4)) - .db #-8, #0xff - .db #0 + pop de + + dec c + jr nz, 1$ - .dw #(0x9000 + (0x2D << 4)) - .db #8 - .db #0xFF, #0xFF, #0xFF, #0xFF, #0xC3, #0xFF, #0xFF, #0xFF - .db #0 - - .dw #(0x9000 + (0x30 << 4)) - .db #80 - .db #0xFF, #0xCF, #0xA7, #0x33, #0x33, #0x33, #0x97, #0xCF - .db #0xFF, #0xCF, #0x8F, #0x0F, #0xCF, #0xCF, #0xCF, #0x03 - .db #0xFF, #0x87, #0x33, #0xE7, #0xCF, #0x9F, #0x3F, #0x03 - .db #0xFF, #0x87, #0x73, #0xF3, #0xC7, #0xF3, #0x73, #0x87 - .db #0xFF, #0xC7, #0xA7, #0x67, #0x03, #0xE7, #0xE7, #0xE7 - .db #0xFF, #0x03, #0x3F, #0x3F, #0x87, #0xF3, #0x33, #0x87 - .db #0xFF, #0x87, #0x33, #0x3F, #0x07, #0x33, #0x33, #0x87 - .db #0xFF, #0x03, #0xF3, #0xF3, #0xE7, #0xE7, #0xCF, #0xCF - .db #0xFF, #0x87, #0x33, #0x33, #0x87, #0x33, #0x33, #0x87 - .db #0xFF, #0x87, #0x33, #0x33, #0x83, #0xF3, #0x33, #0x87 - .db #0 - - .dw #(0x9000 + (0x3A << 4)) - .db #8 - .db #0xFF, #0xFF, #0x9F, #0x9F, #0xFF, #0x9F, #0x9F, #0xFF - .db #0 - - .dw #(0x9000 + (0x41 << 4)) - .db #66 - .db #0xFF, #0xCF, #0xB7, #0x7B, #0x7B, #0x03, #0x7B, #0x7B - .db #0xFF, #0x07, #0x7B, #0x7B, #0x07, #0x7B, #0x7B, #0x07 - .db #0xFF, #0xC3, #0xBF, #0x7F, #0x7F, #0x7F, #0xBF, #0xC3 - .db #0xFF, #0x0F, #0x77, #0x7B, #0x7B, #0x7B, #0x77, #0x0F - .db #0xFF, #0x03, #0x7F, #0x7F, #0x03, #0x7F, #0x7F, #0x03 - .db #0xFF, #0x03, #0x7F, #0x7F, #0x03, #0x7F, #0x7F, #0x7F - .db #0xFF, #0x83, #0x7F, #0x7F, #0x43, #0x7B, #0x7B, #0x87 - .db #0xFF, #0x7B, #0x7B, #0x7B, #0x03, #0x7B, #0x7B, #0x7B - .db #0xFF, #0x83 - .db #-5, #0xef - .db #2 - .db #0x83, #0xFF - .db #-6, #0xfb - .db #10 - .db #0x07, #0xFF, #0x7B, #0x77, #0x6F, #0x5F, #0x1F, #0x6F - .db #0x73, #0xFF - .db #-6, #0x7f - .db #19 - .db #0x03, #0xFF, #0x7B, #0x33, #0x4B, #0x7B, #0x7B, #0x7B - .db #0x7B, #0xFF, #0x7B, #0x3B, #0x5B, #0x6B, #0x73, #0x7B - .db #0x7B, #0xFF, #0x87 - .db #-5, #0x7b - .db #35 - .db #0x87, #0xFF, #0x07, #0x7B, #0x7B, #0x07, #0x7F, #0x7F - .db #0x7F, #0xFF, #0x87, #0x7B, #0x7B, #0x7B, #0x5B, #0x67 - .db #0x93, #0xFF, #0x07, #0x7B, #0x7B, #0x07, #0x6F, #0x77 - .db #0x7B, #0xFF, #0x83, #0x7F, #0x7F, #0x87, #0xFB, #0x7B - .db #0x87, #0xFF, #0x01 - .db #-6, #0xef - .db #1 - .db #0xFF - .db #-6, #0x7b - .db #2 - .db #0x87, #0xFF - .db #-5, #0x7b - .db #34 - .db #0xB7, #0xCF, #0xFF, #0x7B, #0x7B, #0x7B, #0x7B, #0x4B - .db #0x33, #0x7B, #0xFF, #0x7B, #0x7B, #0xB7, #0xCF, #0xB7 - .db #0x7B, #0x7B, #0xFF, #0xBB, #0xBB, #0xBB, #0xD7, #0xEF - .db #0xEF, #0xEF, #0xFF, #0x03, #0xFB, #0xF7, #0xEF, #0xDF - .db #0xBF, #0x03 - .db #0 - .dw #0 + add sp, #2 + ret .header: ; 0123456789ABCDEFGHI 19 chars diff --git a/gbdk-lib/libc/gb/f_ibm_sh.s b/gbdk-lib/libc/gb/f_ibm_sh.s @@ -2,15 +2,6 @@ ;; BANKED: checked, imperfect .area _BASE - .globl font_load - ;; Perform tricks with banking to shift this font out of - ;; bank 0. Doesnt currently work as the encoding table - ;; must always be visible. -_font_load_ibm:: ; Banked - ld hl,#_font_ibm - call font_load - ret - ; 898 bytes giving ' '-'0'-'@'-'A'-'Z'-'???'-'a'-'z'-127 _font_ibm:: .byte 1+4 ; 128 character encoding diff --git a/gbdk-lib/libc/gb/font.s b/gbdk-lib/libc/gb/font.s @@ -66,6 +66,12 @@ font_table:: rst 0x28 .area _BASE + +_font_load_ibm:: ; Banked + ld hl,#_font_ibm + call font_load + ret + ; Copy uncompressed 16 byte tiles from (BC) to (HL), length = DE*2 ; Note: HL must be aligned on a UWORD boundry font_copy_uncompressed:: @@ -363,7 +369,6 @@ font_set:: xor a ld (font_first_free_tile),a - .globl _font_load_ibm call _font_load_ibm 3$: pop af diff --git a/gbdk-support/ChangeLog b/gbdk-support/ChangeLog @@ -1,12 +1,12 @@ gbdk3-4.0.2 - Updated documentation - - Library was improved - - Linking with stdio.h does not require that much rom now - - Default font is changed to the smaller one (102 characters), that leaves space for user tiles - - Fixed broken support for multiplying longs - - Multiple minor improvements - - New bankpack feature, allows automatic bank allocation for data and code, see banks_autobank example, feature is in beta state, use with care - - Lcc improvements + - Library was improved + - Linking with stdio.h does not require that much rom now + - Default font is changed to the smaller one (102 characters), that leaves space for user tiles + - Fixed broken support for multiplying longs + - Multiple minor improvements + - New bankpack feature, allows automatic bank allocation for data and code, see banks_autobank example, feature is in beta state, use with care + - Lcc improvements gbdk3-4.0.1 - Updated documentation
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.