diff --git a/cli/minimal/Makefile b/cli/minimal/Makefile new file mode 100644 index 0000000..80baa8b --- /dev/null +++ b/cli/minimal/Makefile @@ -0,0 +1,31 @@ +# ************************************************************************************** +# +# Very minimal makefile. +# +# ************************************************************************************** + +# +# Path / Name of emulator. +# +EMULATOR = emu_linux_x64 +# +# 64tass optios. +# +ASMOPTS = -b -w -x + +# +# Assemble the source +# +assemble: + 64tass test.asm $(ASMOPTS) -otest.xex -Ltest.lst +# +# Run program without break. +# +run: assemble + $(EMULATOR) -q file=test.xex + +# +# Run program and break on 65816 NOP ($EA) +# +runbrk: assemble + $(EMULATOR) -q file=test.xex break=EA diff --git a/cli/minimal/test.asm b/cli/minimal/test.asm new file mode 100644 index 0000000..88dbddb --- /dev/null +++ b/cli/minimal/test.asm @@ -0,0 +1,38 @@ +; ************************************************************************************** +; +; The worlds most simple test program. +; +; ************************************************************************************** + + .autsiz ; generate code based on last REP/SEP +; +; Start code at $200 (e.g. above zero page and stack) +; +ProgramStart = $200 + + * = ProgramStart-6 + .word $FFFF ; first word of XEX file + .word ProgramStart ; first byte to copy + .word ProgramEnd-1 ; last byte to copy + +; +; This is the main code block. +; + nop ; so we can test the breakpoint. + clc ; switch to 65816 mode + xce + rep #$30 ; 16 bit AXY + dec a ; A will be $FFFF hence 16 bit. + ldx #$ABCD + +h1: jmp h1 + +ProgramEnd: + +; +; The vector block follows, loaded into $FFE0 ... $FFFF +; + .word $FFE0 + .word $FFFF + .word 0, 0, 0, 0, 0, 0, 0, 0 + .word 0, 0, 0, 0, 0, 0, ProgramStart, 0 \ No newline at end of file diff --git a/cli/text/Makefile b/cli/text/Makefile new file mode 100644 index 0000000..585dc33 --- /dev/null +++ b/cli/text/Makefile @@ -0,0 +1,31 @@ +# ************************************************************************************** +# +# Very minimal makefile. +# +# ************************************************************************************** + +# +# Path / Name of emulator. +# +EMULATOR = emu_linux_x64 +# +# 64tass optios. +# +ASMOPTS = -b -w -x + +# +# Assemble the source +# +assemble: + 64tass text.asm $(ASMOPTS) -otext.xex -Ltext.lst +# +# Run program without break. +# +run: assemble + x65emu -q file=text.xex + +# +# Run program and break on 65816 NOP ($EA) +# +runbrk: assemble + x65emu -q file=text.xex break=EA diff --git a/cli/text/os816/cgia.inc b/cli/text/os816/cgia.inc new file mode 100644 index 0000000..c14f9a3 --- /dev/null +++ b/cli/text/os816/cgia.inc @@ -0,0 +1,97 @@ +.define CGIA_COLUMN_PX 8 + +.define CGIA_DL_MODE_BIT %00001000 +.define CGIA_DL_DLI_BIT %10000000 + +.define CGIA_PLANE_REGS_NO 16 + +.struct CGIA_PLANE_REGS + regs .byte CGIA_PLANE_REGS_NO +.endstruct + +.define CGIA_PLANES 4 +.define CGIA_AFFINE_FRACTIONAL_BITS 8 +.define CGIA_MAX_DL_INSTR 32 + +.define PLANE_MASK_TRANSPARENT %00000001 +.define PLANE_MASK_BORDER_TRANSPARENT %00001000 +.define PLANE_MASK_DOUBLE_WIDTH %00010000 + +.struct CGIA_PLANE_FG + flags .byte + border_columns .byte + row_height .byte + stride .byte + scroll_x .byte + offset_x .byte + scroll_y .byte + offset_y .byte + shared_color0 .byte + shared_color1 .byte +.endstruct + +.struct CGIA_PWM + freq .word + duty .byte + .byte +.endstruct + +.define CGIA_PWMS 2 + +.struct CGIA + .org $FF00 + + mode .byte + bckgnd_bank .byte + sprite_bank .byte + .byte (16-3) ; reserved + + raster .word + .byte (6) ; reserved + int_raster .word + int_enable .byte + int_status .byte + .byte (4) ; reserved + + pwm0 .tag CGIA_PWM + pwm1 .tag CGIA_PWM + .tag CGIA_PWM ; reserved + .tag CGIA_PWM ; reserved + + planes .byte ; [TTTTEEEE] EEEE - enable bits, TTTT - type (0 bckgnd, 1 sprite) + back_color .byte + .byte (8-2) ; reserved + offset0 .word ; // DisplayList or SpriteDescriptor table start + offset1 .word + offset2 .word + offset3 .word + plane0 .tag CGIA_PLANE_REGS + plane1 .tag CGIA_PLANE_REGS + plane2 .tag CGIA_PLANE_REGS + plane3 .tag CGIA_PLANE_REGS +.endstruct + +.define CGIA_REG_INT_FLAG_VBI %10000000 +.define CGIA_REG_INT_FLAG_DLI %01000000 +.define CGIA_REG_INT_FLAG_RSI %00100000 + +text_mode_fg_color = 150; // 0x96 +text_mode_bg_color = 145; // 0x91 + +CGIA_DL_IN_EMPTY_LINE = $00 +CGIA_DL_IN_DUPL_LINE = $01 +CGIA_DL_IN_JUMP = $02 +CGIA_DL_IN_LOAD_SCAN = $03 +CGIA_DL_IN_LMS = %00010000 +CGIA_DL_IN_LFS = %00100000 +CGIA_DL_IN_LBS = %01000000 +CGIA_DL_IN_LCG = %10000000 +CGIA_DL_IN_VBL = %10000000 + +CGIA_DL_IN_MODE2 = $0A +CGIA_DL_IN_MODE3 = $0B +CGIA_DL_IN_MODE4 = $0C +CGIA_DL_IN_MODE5 = $0D +CGIA_DL_IN_MODE6 = $0E +CGIA_DL_IN_MODE7 = $0F + diff --git a/cli/text/os816/dspl.asm b/cli/text/os816/dspl.asm new file mode 100644 index 0000000..7159594 --- /dev/null +++ b/cli/text/os816/dspl.asm @@ -0,0 +1,98 @@ +; Display initialisation +; +; This assumes CIO is ready and S: is after init +; +.export dspl_init + +.include "hw/cgia.inc" +.include "hw/ria.inc" + +.include "macros.inc" + +.segment "DISPLAY" +.org $2000 +dspl_text_buffer: +dspl_fg_buffer = dspl_text_buffer + $1000 +dspl_bg_buffer = dspl_fg_buffer + $0800 +dspl_chargen = dspl_text_buffer + $0800 +.reloc + +dspl_buffer_width = 48 +dspl_buffer_height = 30 +dspl_buffer_size = dspl_buffer_width * dspl_buffer_height + +.segment "RODATA" +dspl_display_list: + .byte CGIA_DL_IN_LOAD_SCAN | CGIA_DL_IN_LMS|CGIA_DL_IN_LFS|CGIA_DL_IN_LBS|CGIA_DL_IN_LCG + .addr dspl_text_buffer + .addr dspl_fg_buffer + .addr dspl_bg_buffer + .addr dspl_chargen + .res 30, CGIA_DL_IN_MODE2 + .byte CGIA_DL_IN_JUMP | CGIA_DL_IN_VBL + .addr dspl_display_list + +.code +.a16 +.i16 +dspl_init: + ; initialize CGIA + stz CGIA::mode + stz CGIA::planes + ; clear all CGIA registers + ldx #CGIA::mode + ldy #CGIA::mode+2 + lda #.sizeof(CGIA) - 3 + mvn 0,0 + + ; set initial buffer values + stz dspl_text_buffer + _a8 + lda #text_mode_fg_color + sta dspl_fg_buffer + lda #text_mode_bg_color + sta dspl_bg_buffer + + ; fetch character generator from RIA firmware + phb + pla + sta RIA::stack ; bank address + lda #>dspl_chargen ; high byte + sta RIA::stack + lda #dispFontData ; high byte + sta RIA_Stack + lda #