woz64/main.asm

149 lines
4.3 KiB
NASM
Raw Normal View History

2019-12-28 21:48:56 +00:00
BasicUpstart2(start)
2019-11-23 02:50:25 +00:00
#import "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
.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
//------------------------------------------------------------------------------------
2019-11-10 03:10:52 +00:00
#import "screen.asm"
2019-11-16 22:09:22 +00:00
#import "keyb2.asm"
2019-11-17 07:41:00 +00:00
#import "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
coldstart:
2019-11-10 03:10:52 +00:00
ldx #$FF
2019-11-06 04:31:17 +00:00
sei
2019-11-10 03:10:52 +00:00
txs
cld
2019-12-28 01:00:13 +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
2019-12-28 01:00:13 +00:00
* = * "App Start"
2019-11-21 06:18:23 +00:00
//------------------------------------------------------------------------------------
2019-11-06 04:31:17 +00:00
start:
jsr initApp;
2019-12-28 01:00:13 +00:00
print(lineString)
2019-11-06 04:31:17 +00:00
print(testString)
2019-12-28 01:00:13 +00:00
print(lineString)
2019-11-16 22:09:22 +00:00
loop:
lda #$FF
2019-12-28 01:00:13 +00:00
Raster: cmp RASTER_LINE // Raster done?
2019-11-23 02:50:25 +00:00
bne Raster
2019-11-16 22:09:22 +00:00
jsr Keyboard2.ReadKeyb
jsr Keyboard2.GetKey
2019-11-21 06:18:23 +00:00
bcs loop
2019-12-28 01:00:13 +00:00
2019-11-21 06:18:23 +00:00
cmp #CR
2019-12-28 01:00:13 +00:00
beq execute
2019-11-16 22:09:22 +00:00
2019-11-21 06:18:23 +00:00
cmp #BS
beq backspace
inputChar:
2019-12-28 01:00:13 +00:00
jsr Shell.push // Char in Buffer
2019-11-21 06:18:23 +00:00
cPrint()
jmp loop
backspace:
jsr Shell.backspace
cPrint()
jmp loop
2019-12-28 01:00:13 +00:00
execute:
jsr Shell.push // CR in Buffer
2019-11-17 08:52:55 +00:00
jsr Screen.screenNewLine
2019-12-28 01:00:13 +00:00
jsr Shell.exec
2019-11-17 08:52:55 +00:00
jsr Screen.screenNewLine
2019-11-17 07:41:00 +00:00
jsr Shell.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
lda #$7f
2019-12-28 01:00:13 +00:00
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.
2019-11-23 02:50:25 +00:00
2019-12-28 01:00:13 +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.
// we don't want that to happen.
2019-11-23 02:50:25 +00:00
// Disable 0e TIMER
2019-11-21 06:18:23 +00:00
lda #254
2019-12-28 01:00:13 +00:00
and TIMER_A_CTRL
sta TIMER_A_CTRL
2019-11-21 06:18:23 +00:00
2019-11-06 04:31:17 +00:00
ClearColorRam($00)
2019-12-28 01:00:13 +00:00
ClearScreen(' ')
2019-11-21 06:18:23 +00:00
SetBorderColor(BORDER_COLOR)
SetBackgroundColor(MAIN_COLOR)
2019-11-06 04:31:17 +00:00
jsr Screen.init
2019-11-16 22:09:22 +00:00
jsr Keyboard2.init
2019-11-17 07:41:00 +00:00
jsr Shell.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
//------------------------------------------------------------------------------------
* = * "Hoax"
hoax: {
print(hoaxString)
jmp loop
}
2019-11-16 22:09:22 +00:00
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
.encoding "screencode_mixed"
2019-11-21 06:18:23 +00:00
2019-11-23 02:50:25 +00:00
version: .byte 00
revision: .byte 01
minor: .byte 05
2019-11-06 04:31:17 +00:00
testString:
2019-11-23 02:50:25 +00:00
.text "woz64 mon - v 0.1.5"
2019-12-28 01:00:13 +00:00
.byte $8e, 0
lineString:
2019-11-17 08:52:55 +00:00
.text "----------------------------------------"
.byte $8e, 0
2019-11-21 06:18:23 +00:00
hoaxString:
.text "=stid= 1972"
.byte $8e, 0
2019-11-06 04:31:17 +00:00
* = $9FFF "EpromFiller"
.byte 0