2020/c64/main.asm

149 lines
2.2 KiB
NASM
Raw Normal View History

2020-12-06 17:07:35 +00:00
// vim: filetype=kickass
2020-12-06 17:07:35 +00:00
#import "math.inc"
BasicUpstart2(main)
2020-12-06 17:07:35 +00:00
* = $1000 "Main program"
2020-12-06 17:07:35 +00:00
.const SCREEN_RAM = $0400
.const COLOR_RAM = $d800
.const kernal_scinit = $ff81
.const kernal_chrout = $ffd2
.const kernal_write_byte = $e716
.const zp_temp = $02
.const cursor_pointer_lo = $05
.const cursor_pointer_hi = $06
2020-12-09 02:13:51 +00:00
.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
2020-12-06 17:07:35 +00:00
//
// main
//
main:
jsr clear_screen
// Swap out BASIC and kernal
sei
lda %00110000
sta $01
jsr generate_multiplication_tables
jsr tree_clear
//jsr test_tree
2020-12-09 01:08:57 +00:00
jsr day01
2020-12-06 17:07:35 +00:00
!loop:
jmp !loop-
#import "day01.asm"
2020-12-06 17:07:35 +00:00
#import "screen.asm"
#import "math.asm"
#import "btree.asm"
2020-12-09 08:01:02 +00:00
* = * "Day 01 Input"
day01_input:
.import text "../rust/inputs/day01"
.byte 0