Wow
This commit is contained in:
parent
a10046974a
commit
4807c82bf9
@ -16,40 +16,126 @@ EntryPoint:
|
|||||||
ClearOAM
|
ClearOAM
|
||||||
LoadTiles
|
LoadTiles
|
||||||
|
|
||||||
PrintString calculating_string, 3, 6
|
MemClear current_frame, 1
|
||||||
|
MemClear current_floor, 2
|
||||||
|
MemClear done_flag, 1
|
||||||
|
|
||||||
|
;; Initialize input_index
|
||||||
|
ld bc, input
|
||||||
|
ld a, b
|
||||||
|
ld [input_index], a
|
||||||
|
ld a, c
|
||||||
|
ld [input_index + 1], a
|
||||||
|
|
||||||
FinishInit
|
FinishInit
|
||||||
Done:
|
|
||||||
ei
|
ei
|
||||||
|
|
||||||
|
CheckInput:
|
||||||
|
ld a, [input_index]
|
||||||
|
ld h, a
|
||||||
|
ld a, [input_index + 1]
|
||||||
|
ld l, a
|
||||||
|
ld a, [hl]
|
||||||
|
|
||||||
|
cp a, "("
|
||||||
|
jr z, GoingUp
|
||||||
|
jr GoingDown
|
||||||
|
GoingUp:
|
||||||
|
call IncrementCurrentFloor
|
||||||
|
jr GoingNowhere
|
||||||
|
GoingDown:
|
||||||
|
call DecrementCurrentFloor
|
||||||
|
GoingNowhere:
|
||||||
|
|
||||||
|
IncrementWord input_index
|
||||||
|
|
||||||
|
ld de, input_end
|
||||||
|
ld a, [input_index]
|
||||||
|
sub a, d
|
||||||
|
jr nz, CheckInput
|
||||||
|
|
||||||
|
ld a, [input_index + 1]
|
||||||
|
sub a, e
|
||||||
|
jr nz, CheckInput
|
||||||
|
|
||||||
|
ld a, 1
|
||||||
|
ld [done_flag], a
|
||||||
|
|
||||||
|
Done:
|
||||||
|
|
||||||
halt
|
halt
|
||||||
nop
|
nop
|
||||||
jr Done
|
jr Done
|
||||||
|
|
||||||
|
IncrementCurrentFloor:
|
||||||
|
ld hl, current_floor
|
||||||
|
ld a, [hli]
|
||||||
|
ld b, a
|
||||||
|
ld a, [hli]
|
||||||
|
ld c, a
|
||||||
|
|
||||||
|
inc bc
|
||||||
|
|
||||||
|
ld hl, current_floor
|
||||||
|
ld a, b
|
||||||
|
ld [hli], a
|
||||||
|
ld a, c
|
||||||
|
ld [hli], a
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
DecrementCurrentFloor:
|
||||||
|
ld hl, current_floor
|
||||||
|
ld a, [hli]
|
||||||
|
ld b, a
|
||||||
|
ld a, [hli]
|
||||||
|
ld c, a
|
||||||
|
|
||||||
|
dec bc
|
||||||
|
|
||||||
|
ld hl, current_floor
|
||||||
|
ld a, b
|
||||||
|
ld [hli], a
|
||||||
|
ld a, c
|
||||||
|
ld [hli], a
|
||||||
|
|
||||||
|
ret
|
||||||
|
ret
|
||||||
|
|
||||||
VBlankHandler:
|
VBlankHandler:
|
||||||
ld a, [current_frame]
|
push AF
|
||||||
inc a
|
push BC
|
||||||
ld [current_frame], a
|
push DE
|
||||||
PrintByte current_frame
|
push HL
|
||||||
|
|
||||||
|
IncrementFrameCount
|
||||||
|
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
|
||||||
|
PrintString done_string, 3, 3
|
||||||
|
|
||||||
|
NotDone:
|
||||||
|
pop HL
|
||||||
|
pop DE
|
||||||
|
pop BC
|
||||||
|
pop AF
|
||||||
reti
|
reti
|
||||||
|
|
||||||
SECTION "High RAM", HRAM
|
SECTION "High RAM", HRAM
|
||||||
current_frame: DS 1
|
|
||||||
current_frame_end:
|
|
||||||
|
|
||||||
current_floor: DS 2
|
current_floor: DS 2
|
||||||
|
done_flag: DS 1
|
||||||
input_index: DS 2
|
|
||||||
|
|
||||||
print_byte_string: DS 2
|
|
||||||
print_byte_string_end:
|
|
||||||
|
|
||||||
SECTION "Input", ROM0
|
SECTION "Input", ROM0
|
||||||
input:
|
input:
|
||||||
INCBIN "../data/2015/1/input.txt"
|
INCBIN "../data/2015/1/input.txt"
|
||||||
input_end:
|
input_end:
|
||||||
|
|
||||||
calculating_string:
|
done_string:
|
||||||
db "Calculating...42069", 0
|
db "Done", 0
|
||||||
calculating_string_end:
|
done_string_end:
|
||||||
|
|
||||||
INCLUDE "lib/tiles.asm"
|
INCLUDE "lib/tiles.asm"
|
||||||
|
@ -16,5 +16,6 @@ set -e
|
|||||||
rgbasm -o $year/$day/main.o $source_file -H -Wall
|
rgbasm -o $year/$day/main.o $source_file -H -Wall
|
||||||
rgblink -o $year/$day/main.gb $year/$day/main.o
|
rgblink -o $year/$day/main.gb $year/$day/main.o
|
||||||
rgbfix -v -p 0xFF $year/$day/main.gb
|
rgbfix -v -p 0xFF $year/$day/main.gb
|
||||||
|
|
||||||
wine bin/bgb.exe $year/$day/main.gb
|
wine bin/bgb.exe $year/$day/main.gb
|
||||||
|
|
||||||
|
@ -38,10 +38,10 @@ MACRO ClearScreen
|
|||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
MACRO PrintString
|
MACRO PrintString
|
||||||
MemCopy (_SCRN0 + (\2 << 5) + \3), \1
|
MemCopy (_SCRN0 + (\3 << 5) + \2), \1
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
MACRO PrintByte
|
MACRO PrintByteHex
|
||||||
ld hl, \1
|
ld hl, \1
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
and a, $F0
|
and a, $F0
|
||||||
@ -61,13 +61,51 @@ MACRO PrintByte
|
|||||||
add a, "A" - "0" - 10
|
add a, "A" - "0" - 10
|
||||||
.low_carry\@
|
.low_carry\@
|
||||||
ld c, a
|
ld c, a
|
||||||
ld hl, print_byte_string
|
ld hl, print_byte_hex_string
|
||||||
ld a, b
|
ld a, b
|
||||||
ldi [hl], a
|
ldi [hl], a
|
||||||
ld a, c
|
ld a, c
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
|
|
||||||
PrintString print_byte_string, 0, 0
|
PrintString print_byte_hex_string, \2, \3
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
MACRO PrintByte
|
||||||
|
ld hl, \1
|
||||||
|
xor a
|
||||||
|
ld b, a
|
||||||
|
ld c, a
|
||||||
|
ld a, [hl]
|
||||||
|
.hundreds\@
|
||||||
|
cp a, 100
|
||||||
|
jr c, .hundreds_done\@
|
||||||
|
sub a, 100
|
||||||
|
inc b
|
||||||
|
jr .hundreds\@
|
||||||
|
.hundreds_done\@
|
||||||
|
|
||||||
|
.tens\@
|
||||||
|
cp a, 10
|
||||||
|
jr c, .tens_done\@
|
||||||
|
sub a, 10
|
||||||
|
inc c
|
||||||
|
jr .tens\@
|
||||||
|
.tens_done\@
|
||||||
|
|
||||||
|
ld d, a
|
||||||
|
|
||||||
|
ld hl, print_byte_string
|
||||||
|
ld a, b
|
||||||
|
add a, "0"
|
||||||
|
ldi [hl], a
|
||||||
|
ld a, c
|
||||||
|
add a, "0"
|
||||||
|
ldi [hl], a
|
||||||
|
ld a, d
|
||||||
|
add a, "0"
|
||||||
|
ldi [hl], a
|
||||||
|
|
||||||
|
PrintString print_byte_string, \2, \3
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
MACRO StartInit
|
MACRO StartInit
|
||||||
@ -107,3 +145,35 @@ MACRO FinishInit
|
|||||||
|
|
||||||
ldh [rLCDC], a
|
ldh [rLCDC], a
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
|
MACRO IncrementFrameCount
|
||||||
|
ld a, [current_frame]
|
||||||
|
inc a
|
||||||
|
ld [current_frame], a
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
MACRO IncrementWord
|
||||||
|
ld a, [\1]
|
||||||
|
ld b, a
|
||||||
|
ld a, [\1 + 1]
|
||||||
|
ld c, a
|
||||||
|
inc bc
|
||||||
|
ld a, b
|
||||||
|
ld [\1], a
|
||||||
|
ld a, c
|
||||||
|
ld [\1 + 1], a
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
SECTION "Macro HRAM", HRAM
|
||||||
|
current_frame: DS 2
|
||||||
|
current_frame_end:
|
||||||
|
|
||||||
|
input_index: DS 2
|
||||||
|
|
||||||
|
print_byte_hex_string:
|
||||||
|
print_byte_string:
|
||||||
|
DS 2
|
||||||
|
print_byte_hex_string_end:
|
||||||
|
DS 1
|
||||||
|
print_byte_string_end:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user