2020/c64/main.asm

185 lines
3.3 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
}
}
//
// 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 "screen.asm"
#import "math.asm"
#import "menu.asm"
*=$2000 "Sprite"
.align 64
sprite1:
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $A0
.byte $00, $0A, $B8
.byte $00, $AB, $F8
.byte $0A, $BF, $FE
.byte $AB, $FF, $FE
.byte $BF, $FF, $FF
.byte $BF, $FF, $FD
.byte $BF, $FF, $D5
.byte $BF, $FD, $57
.byte $2F, $D5, $7F
.byte $2D, $57, $FF
.align 64
sprite2:
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $80, $00, $00
.byte $80, $00, $00
.byte $A0, $00, $00
.byte $E0, $00, $00
.byte $E8, $02, $80
.align 64
sprite3:
.byte $09, $7F, $FF
.byte $0B, $FF, $FF
.byte $0B, $FF, $F5
.byte $02, $FF, $5A
.byte $02, $F5, $5B
.byte $00, $95, $FA
.byte $00, $9F, $FE
.byte $00, $BF, $FE
.byte $00, $2F, $FF
.byte $00, $2F, $FF
.byte $00, $0B, $F5
.byte $00, $0B, $55
.byte $00, $09, $5F
.byte $00, $02, $FF
.byte $00, $02, $BF
.byte $00, $00, $BF
.byte $00, $00, $AE
.byte $00, $00, $2A
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.align 64
sprite4:
.byte $F8, $2B, $80
.byte $FA, $BF, $E0
.byte $EB, $FF, $E0
.byte $BF, $FF, $E0
.byte $FF, $FF, $E0
.byte $FF, $FF, $F8
.byte $FF, $FF, $D8
.byte $FF, $FD, $58
.byte $BF, $D5, $78
.byte $BD, $57, $F8
.byte $95, $7F, $E0
.byte $97, $FF, $E0
.byte $BF, $FF, $A0
.byte $BF, $FE, $80
.byte $BF, $FA, $00
.byte $BF, $A8, $00
.byte $FA, $80, $00
.byte $A8, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.byte $00, $00, $00
.align 256
flip_map:
.for (var i = 0; i < 256; i++) {
// 11001001 >> 6 = 11 & $03 == 11
// 11001001 >> 2 = 110010 & $0c == 00
// 11001001 << 2 = 001001 & $30 == 10
// 11001001 << 6 = 01 & $c0 == 01
// -------- |
// 01100011
.byte ((i >> 6) & $03) | ((i >> 2) & $0c) | ((i << 2) & $30) | ((i << 6) & $c0)
}
#import "day01.asm"
#import "day02.asm"
#import "day05.asm"
#import "day09.asm"
#import "btree.asm"