Wow
This commit is contained in:
parent
a10046974a
commit
4807c82bf9
@ -16,40 +16,126 @@ EntryPoint:
|
||||
ClearOAM
|
||||
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
|
||||
Done:
|
||||
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
|
||||
nop
|
||||
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:
|
||||
ld a, [current_frame]
|
||||
inc a
|
||||
ld [current_frame], a
|
||||
PrintByte current_frame
|
||||
push AF
|
||||
push BC
|
||||
push DE
|
||||
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
|
||||
|
||||
SECTION "High RAM", HRAM
|
||||
current_frame: DS 1
|
||||
current_frame_end:
|
||||
|
||||
current_floor: DS 2
|
||||
|
||||
input_index: DS 2
|
||||
|
||||
print_byte_string: DS 2
|
||||
print_byte_string_end:
|
||||
done_flag: DS 1
|
||||
|
||||
SECTION "Input", ROM0
|
||||
input:
|
||||
INCBIN "../data/2015/1/input.txt"
|
||||
input_end:
|
||||
|
||||
calculating_string:
|
||||
db "Calculating...42069", 0
|
||||
calculating_string_end:
|
||||
done_string:
|
||||
db "Done", 0
|
||||
done_string_end:
|
||||
|
||||
INCLUDE "lib/tiles.asm"
|
||||
|
@ -16,5 +16,6 @@ set -e
|
||||
rgbasm -o $year/$day/main.o $source_file -H -Wall
|
||||
rgblink -o $year/$day/main.gb $year/$day/main.o
|
||||
rgbfix -v -p 0xFF $year/$day/main.gb
|
||||
|
||||
wine bin/bgb.exe $year/$day/main.gb
|
||||
|
||||
|
@ -38,10 +38,10 @@ MACRO ClearScreen
|
||||
ENDM
|
||||
|
||||
MACRO PrintString
|
||||
MemCopy (_SCRN0 + (\2 << 5) + \3), \1
|
||||
MemCopy (_SCRN0 + (\3 << 5) + \2), \1
|
||||
ENDM
|
||||
|
||||
MACRO PrintByte
|
||||
MACRO PrintByteHex
|
||||
ld hl, \1
|
||||
ld a, [hl]
|
||||
and a, $F0
|
||||
@ -61,13 +61,51 @@ MACRO PrintByte
|
||||
add a, "A" - "0" - 10
|
||||
.low_carry\@
|
||||
ld c, a
|
||||
ld hl, print_byte_string
|
||||
ld hl, print_byte_hex_string
|
||||
ld a, b
|
||||
ldi [hl], a
|
||||
ld a, c
|
||||
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
|
||||
|
||||
MACRO StartInit
|
||||
@ -106,4 +144,36 @@ MACRO FinishInit
|
||||
ld a, LCDCF_ON | LCDCF_BGON | LCDCF_WINON | LCDCF_WIN9C00 | LCDCF_OBJON | LCDCF_OBJ8 | LCDCF_BG8800
|
||||
|
||||
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