2020/c64/main.asm

150 lines
2.2 KiB
NASM

// vim: filetype=kickass
#import "math.inc"
BasicUpstart2(main)
* = $1000 "Main program"
.const SCREEN_RAM = $0400
.const COLOR_RAM = $d800
.const zp_temp = $02
.const cursor_pointer_lo = $05
.const cursor_pointer_hi = $06
.macro move_16_imm(dst, imm) {
lda #<imm
sta dst
lda #>imm
sta dst + 1
}
.macro u16_u16_move(dst, src) {
.for (var i = 0; i < 2; i++) {
lda src + i
sta dst + i
}
}
.macro u32_u32_move(dst, src) {
.for (var i = 0; i < 4; i++) {
lda src + i
sta dst + i
}
}
.macro u32_u32_move_imm(dst, imm) {
.for (var i = 0; i < 4; i++) {
lda #((imm >> (i * 8)) & $ff)
sta dst + i
}
}
test_tree:
move_16_imm($03, !str_test+)
jsr write_string
move_16_imm($03, $10)
jsr tree_insert
move_16_imm($03, $08)
jsr tree_insert
move_16_imm($03, $04)
jsr tree_insert
move_16_imm($03, $12)
jsr tree_insert
move_16_imm($03, $1337)
jsr tree_insert
move_16_imm($03, $08)
jsr tree_contains
bne !fail+
move_16_imm($03, $13)
jsr tree_contains
beq !fail+
move_16_imm($03, $12)
jsr tree_contains
bne !fail+
move_16_imm($03, $1337)
jsr tree_contains
bne !fail+
move_16_imm($03, $0420)
jsr tree_contains
beq !fail+
move_16_imm($03, !str_success+)
jsr write_string
rts
!fail:
u16_u16_move($10, $03)
move_16_imm($03, !str_fail+)
jsr write_string
lda $11
jsr print_hex_0x
lda $10
jsr print_hex
jsr print_newline
rts
!str_test:
.text "[ ] test-tree"
.byte '\r', 0
!str_fail:
.text "[!!]"
.byte '\n'
.text "Failed: "
.byte 0
!str_success:
.text "[OK]"
.byte '\n', 0
//
// main
//
main:
sei
lda #$35
sta $01
lda #49
sta $07
jsr setup_interrupt
jsr clear_screen
jsr draw_menu
jsr generate_multiplication_tables
!:
jsr menu_update
jmp !-
#import "day01.asm"
#import "day05.asm"
#import "screen.asm"
#import "math.asm"
#import "btree.asm"
#import "menu.asm"
* = * "Day 01 Input"
day01_input:
.import text "../rust/inputs/day01"
.byte 0
* = * "Day 05 input"
day05_input:
.import text "../inputs/05"
.byte 0