diff --git a/gb/2015/1/not_quite_lisp.asm b/gb/2015/1/not_quite_lisp.asm index 9c4862e..e3e5ad2 100644 --- a/gb/2015/1/not_quite_lisp.asm +++ b/gb/2015/1/not_quite_lisp.asm @@ -16,8 +16,9 @@ EntryPoint: ClearOAM LoadTiles - MemClear current_frame, 1 + MemClear current_frame, 2 MemClear current_floor, 2 + MemClear first_basement_floor, 2 MemClear done_flag, 1 ;; Initialize input_index @@ -39,67 +40,86 @@ CheckInput: cp a, "(" jr z, GoingUp - jr GoingDown + cp a, ")" + jr z, GoingDown + jr GoingNowhere GoingUp: call IncrementCurrentFloor jr GoingNowhere GoingDown: + ld a, [current_floor] + ld b, a + ld a, [current_floor + 1] + and a, b + call z, SaveBasementFloor + call DecrementCurrentFloor GoingNowhere: - IncrementWord input_index ld de, input_end ld a, [input_index] - sub a, d + cp a, d jr nz, CheckInput ld a, [input_index + 1] - sub a, e + cp a, e jr nz, CheckInput ld a, 1 ld [done_flag], a + halt + nop + jr Done + Done: - halt nop jr Done IncrementCurrentFloor: - ld hl, current_floor - ld a, [hli] + ld a, [current_floor] ld b, a - ld a, [hli] + ld a, [current_floor + 1] ld c, a inc bc - ld hl, current_floor ld a, b - ld [hli], a + ld [current_floor], a ld a, c - ld [hli], a + ld [current_floor + 1], a ret DecrementCurrentFloor: - ld hl, current_floor - ld a, [hli] + ld a, [current_floor] ld b, a - ld a, [hli] + ld a, [current_floor + 1] ld c, a dec bc - ld hl, current_floor ld a, b - ld [hli], a + ld [current_floor], a ld a, c - ld [hli], a + ld [current_floor + 1], a ret + +SaveBasementFloor: + ld a, [first_basement_floor] + ld b, a + ld a, [first_basement_floor + 1] + or a, b + ret nz + + ld a, [input_index] + ld [first_basement_floor], a + ld a, [input_index + 1] + ld [first_basement_floor + 1], a + ret VBlankHandler: @@ -109,14 +129,19 @@ VBlankHandler: push HL IncrementFrameCount - PrintByteHex current_frame, 0, 0 - PrintByte current_frame, 0, 1 - PrintByteHex current_floor, 0, 2 - PrintByteHex current_floor + 1, 2, 2 + + PrintString part_1_string, 0, 1 + PrintString part_2_string, 0, 2 + ;; PrintByteHex current_frame, 0, 0 + ;; PrintByte current_frame, 0, 1 + ;; PrintByteHex current_floor, 0, 2 + ;; PrintByteHex current_floor + 1, 2, 2 ld a, [done_flag] cp a, 1 - jr z, NotDone + jp nz, NotDone PrintString done_string, 3, 3 + PrintByte current_floor + 1, 8, 1 + ;; PrintByte first_basement_floor + 1, 8, 2 NotDone: pop HL @@ -126,8 +151,9 @@ NotDone: reti SECTION "High RAM", HRAM -current_floor: DS 2 -done_flag: DS 1 +current_floor: DS 2 +first_basement_floor: DS 2 +done_flag: DS 1 SECTION "Input", ROM0 input: @@ -138,4 +164,10 @@ done_string: db "Done", 0 done_string_end: +part_1_string: db "Part 1: " +part_1_string_end: + +part_2_string: db "Part 2: " +part_2_string_end: + INCLUDE "lib/tiles.asm" diff --git a/gb/bin/run b/gb/bin/run index 3b97017..e2af740 100755 --- a/gb/bin/run +++ b/gb/bin/run @@ -13,7 +13,9 @@ fi set -e -rgbasm -o $year/$day/main.o $source_file -H -Wall +rgbgfx -o lib/text.2bpp lib/text.png + +rgbasm -o $year/$day/main.o $source_file -H -Wall -E rgblink -o $year/$day/main.gb $year/$day/main.o rgbfix -v -p 0xFF $year/$day/main.gb diff --git a/gb/lib/text.2bpp b/gb/lib/text.2bpp index 3462eee..e86d4d1 100644 Binary files a/gb/lib/text.2bpp and b/gb/lib/text.2bpp differ diff --git a/gb/lib/text.png b/gb/lib/text.png index 1055224..224a7a2 100644 Binary files a/gb/lib/text.png and b/gb/lib/text.png differ