woz64/main.asm

149 lines
4.3 KiB
NASM

BasicUpstart2(start)
#import "mem_map.asm"
* = $8000 "Main"
//------------------------------------------------------------------------------------
.const MAIN_COLOR = $03
.const BORDER_COLOR = $05
.const CR = $0d
.const BS = $14
.const ADV_CHAR = '@'
.const INIT_IRQ = $fda3
.const INIT_MEM = $fd50
.const INIT_IO = $fd15
.const INIT_VID = $ff5b
.const SCRN_CTRL = $d016
.const RASTER_LINE = $d012
.const INTERRUPT_CTRL = $dc0d
.const NMSK_INTERRUPT_CTRL = $dd0d
.const TIMER_A_CTRL = $DC0E
//------------------------------------------------------------------------------------
.word coldstart // coldstart vector
.word start // start vector
.byte $C3,$C2,$CD,'8','0' //..CBM80..
//------------------------------------------------------------------------------------
#import "screen.asm"
#import "keyb2.asm"
#import "shell.asm"
//------------------------------------------------------------------------------------
// Main Program
//------------------------------------------------------------------------------------
* = * "Kernel Start"
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
* = * "App Start"
//------------------------------------------------------------------------------------
start:
jsr initApp;
print(lineString)
print(testString)
print(lineString)
loop:
lda #$FF
Raster: cmp RASTER_LINE // Raster done?
bne Raster
jsr Keyboard2.ReadKeyb
jsr Keyboard2.GetKey
bcs loop
cmp #CR
beq execute
cmp #BS
beq backspace
inputChar:
jsr Shell.push // Char in Buffer
cPrint()
jmp loop
backspace:
jsr Shell.backspace
cPrint()
jmp loop
execute:
jsr Shell.push // CR in Buffer
jsr Screen.screenNewLine
jsr Shell.exec
jsr Screen.screenNewLine
jsr Shell.clear
jmp loop
//------------------------------------------------------------------------------------
initApp: {
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
ClearColorRam($00)
ClearScreen(' ')
SetBorderColor(BORDER_COLOR)
SetBackgroundColor(MAIN_COLOR)
jsr Screen.init
jsr Keyboard2.init
jsr Shell.init
cli
rts
}
//------------------------------------------------------------------------------------
* = * "Hoax"
hoax: {
print(hoaxString)
jmp loop
}
//------------------------------------------------------------------------------------
* = * "Kernel Data"
.encoding "screencode_mixed"
version: .byte 00
revision: .byte 01
minor: .byte 05
testString:
.text "woz64 mon - v 0.1.5"
.byte $8e, 0
lineString:
.text "----------------------------------------"
.byte $8e, 0
hoaxString:
.text "=stid= 1972"
.byte $8e, 0
* = $9FFF "EpromFiller"
.byte 0