2020/c64/main.asm

141 lines
2.1 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 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:
sei
2020-12-15 02:26:53 +00:00
lda #$35
sta $01
2020-12-15 02:26:53 +00:00
lda #49
sta $07
jsr setup_interrupt
2020-12-15 02:26:53 +00:00
jsr clear_screen
jsr draw_menu
2020-12-09 01:08:57 +00:00
2020-12-15 02:26:53 +00:00
jsr generate_multiplication_tables
2020-12-06 17:07:35 +00:00
2020-12-15 02:26:53 +00:00
!:
jsr menu_update
jmp !-
2020-12-06 17:07:35 +00:00
#import "day01.asm"
2020-12-15 02:26:53 +00:00
#import "day05.asm"
2020-12-17 04:36:57 +00:00
#import "day09.asm"
2020-12-06 17:07:35 +00:00
#import "screen.asm"
#import "math.asm"
#import "btree.asm"
2020-12-15 02:26:53 +00:00
#import "menu.asm"