woz64/core/boot.asm

122 lines
3.7 KiB
NASM

#importonce
#import "../core/pseudo.asm"
#import "../core/module.asm"
#import "../core/system.asm"
.filenamespace Boot
.const INIT_IRQ = $fda3
.const INIT_MEM = $fd50
.const INIT_IO = $fd15
.const INIT_VID = $ff5b
.const SCRN_CTRL = $d016
.const MAIN_COLOR = $03
.const BORDER_COLOR = $05
.const INTERRUPT_CTRL = $dc0d
.const NMSK_INTERRUPT_CTRL = $dd0d
.const TIMER_A_CTRL = $DC0E
* = * "Boot Core"
// ========================================================
// ////// METHODS /////////////////////////////////////////
// ========================================================
// --------------------------------------------------------
// coldstart -
// Power ON initialization
// --------------------------------------------------------
coldStart: {
ldx #$FF
sei
txs
cld
stx SCRN_CTRL // Set Screen Bits
jsr INIT_IRQ // Prepare IRQ
jsr INIT_MEM // Init memory. Rewrite this routine to speed up boot process.
jsr INIT_IO // Init I/O
jsr INIT_VID // Init video
cli
jmp warmStart
}
// --------------------------------------------------------
// warmStart -
// Restore pressed or program restart after first Power ON
// --------------------------------------------------------
warmStart: {
sei
lda #$7f
sta INTERRUPT_CTRL // disable timer interrupts which can be generated by the two CIA chips
sta NMSK_INTERRUPT_CTRL // the kernal uses such an interrupt to flash the cursor and scan the keyboard, so we better
// stop it.
lda INTERRUPT_CTRL // by reading this two registers we negate any pending CIA irqs.
lda NMSK_INTERRUPT_CTRL // if we don't do this, a pending CIA irq might occur after we finish setting up our irq.
// we don't want that to happen.
// Disable 0e TIMER
lda #254
and TIMER_A_CTRL
sta TIMER_A_CTRL
ScreenClearColorRam($00)
ScreenClear(' ')
ScreenSetBorderColor(BORDER_COLOR)
ScreenSetBackgroundColor(MAIN_COLOR)
cli
jsr Boot.init // Init Self as Module
jsr System.start // Start Core System
// If System Exit - reboot
// TODO: We can print a message here
// and delay a bit...
jmp warmStart
}
// --------------------------------------------------------
// init -
// Module Init.
// --------------------------------------------------------
init: {
// Sequence matter
jsr Module.init
jsr Pseudo.init
jsr System.init
rts
}
// --------------------------------------------------------
// toDebug -
// Print debug info.
// --------------------------------------------------------
toDebug: {
ModuleToDebug(module_type, module_name, version)
rts
}
// ========================================================
// ////// DATA ////////////////////////////////////////////
// ========================================================
* = * "Boot Core Data"
module_type: .byte Module.TYPES.CORE
version: .byte 1, 0, 0
.encoding "screencode_mixed"
module_name:
.text "boot"
.byte 0
#import "../core/mem_map.asm"