woz64/main.asm

126 lines
4.1 KiB
NASM
Raw Normal View History

2020-01-12 20:57:01 +00:00
.cpu _6502
2020-01-13 00:52:10 +00:00
//BasicUpstart2(start)
2020-01-12 08:10:01 +00:00
#import "./core/mem_map.asm"
2019-11-06 04:31:17 +00:00
* = $8000 "Main"
2019-11-21 06:18:23 +00:00
//------------------------------------------------------------------------------------
2019-11-23 02:50:25 +00:00
.const MAIN_COLOR = $03
.const BORDER_COLOR = $05
.const CR = $0d
.const BS = $14
2019-12-28 01:00:13 +00:00
.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
2020-01-13 01:24:10 +00:00
.const TIMER_A_CTRL = $DC0E
2019-11-21 06:18:23 +00:00
//------------------------------------------------------------------------------------
2019-11-06 04:31:17 +00:00
.word coldstart // coldstart vector
2019-11-10 03:10:52 +00:00
.word start // start vector
.byte $C3,$C2,$CD,'8','0' //..CBM80..
2019-11-06 04:31:17 +00:00
2019-11-21 06:18:23 +00:00
//------------------------------------------------------------------------------------
2020-01-12 08:10:01 +00:00
#import "./core/init.asm"
#import "./libs/print.asm"
#import "./core/screen.asm"
#import "./core/keyboard.asm"
#import "./progs/woz_shell.asm"
2019-11-10 03:10:52 +00:00
2019-11-21 06:18:23 +00:00
//------------------------------------------------------------------------------------
// Main Program
//------------------------------------------------------------------------------------
2019-11-16 22:09:22 +00:00
* = * "Kernel Start"
2019-11-06 04:31:17 +00:00
2020-01-13 01:24:10 +00:00
coldstart: {
ldx #$FF
2019-11-06 04:31:17 +00:00
sei
2019-11-10 03:10:52 +00:00
txs
cld
2020-01-13 01:24:10 +00:00
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
2019-11-06 04:31:17 +00:00
cli
2020-01-13 01:24:10 +00:00
}
2019-12-28 01:00:13 +00:00
* = * "App Start"
2019-11-21 06:18:23 +00:00
//------------------------------------------------------------------------------------
2020-01-13 01:24:10 +00:00
start: {
jsr initApp;
jsr WozShell.start
loop:
lda #$FF
Raster:
cmp RASTER_LINE // Raster done?
bne Raster
jsr Keyboard.ReadKeyb
jsr Keyboard.GetKey
bcs loop
cmp #CR
beq execute
cmp #BS
beq backspace
inputChar:
jsr WozShell.push // Char in Buffer
2020-01-12 08:10:01 +00:00
PrintChar()
2020-01-13 01:24:10 +00:00
jmp loop
backspace:
jsr WozShell.backspace
2020-01-12 08:10:01 +00:00
PrintChar()
2020-01-13 01:24:10 +00:00
jmp loop
execute:
jsr WozShell.push // CR in Buffer
jsr Screen.screenNewLine
jsr WozShell.exec
jsr Screen.screenNewLine
jsr WozShell.clear
jmp loop
}
2019-11-06 04:31:17 +00:00
2019-11-21 06:18:23 +00:00
//------------------------------------------------------------------------------------
2019-11-06 04:31:17 +00:00
initApp: {
2019-11-23 02:50:25 +00:00
sei
2020-01-13 01:24:10 +00:00
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
2019-12-28 01:00:13 +00:00
// stop it.
2019-11-23 02:50:25 +00:00
2020-01-13 01:24:10 +00:00
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.
2019-12-28 01:00:13 +00:00
// we don't want that to happen.
2019-11-23 02:50:25 +00:00
// Disable 0e TIMER
2020-01-13 01:24:10 +00:00
lda #254
and TIMER_A_CTRL
sta TIMER_A_CTRL
2019-11-21 06:18:23 +00:00
2020-01-12 08:10:01 +00:00
ScreenClearColorRam($00)
ScreenClear(' ')
ScreenSetBorderColor(BORDER_COLOR)
ScreenSetBackgroundColor(MAIN_COLOR)
2020-01-13 01:24:10 +00:00
jsr Init.init
2019-11-23 02:50:25 +00:00
cli
2019-11-06 04:31:17 +00:00
rts
}
2019-11-21 06:18:23 +00:00
//------------------------------------------------------------------------------------
2019-11-16 22:09:22 +00:00
* = * "Kernel Data"
2019-11-06 04:31:17 +00:00
* = $9FFF "EpromFiller"
2020-01-12 08:10:01 +00:00
.byte 0
2019-11-06 04:31:17 +00:00