From 5c8866b3c515af842a46b93ed197e94e903fc1e9 Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Sun, 24 Aug 2025 16:18:53 +0100 Subject: [PATCH 01/10] Added very simple non-CA65 example --- .gitignore | 4 ++++ cli/minimal/Makefile | 25 +++++++++++++++++++++++++ cli/minimal/test.asm | 38 ++++++++++++++++++++++++++++++++++++++ src/test816.asm | 2 ++ 4 files changed, 69 insertions(+) create mode 100644 cli/minimal/Makefile create mode 100644 cli/minimal/test.asm diff --git a/.gitignore b/.gitignore index 8dc14ae..47def2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ /build/ /.cache/ +*.lst +*.xex +dap.log +65816 \ No newline at end of file diff --git a/cli/minimal/Makefile b/cli/minimal/Makefile new file mode 100644 index 0000000..50ec943 --- /dev/null +++ b/cli/minimal/Makefile @@ -0,0 +1,25 @@ +# ************************************************************************************** +# +# Very minimal makefile. +# +# ************************************************************************************** + +EMULATOR = x65emu +ASMOPTS = -b -w -x + +# +# Assemble the source +# +assemble: + 64tass test.asm $(ASMOPTS) -otest.xex -Ltest.lst +# +# Run program without break. +# +run: assemble + x65emu file=test.xex + +# +# Run program and break on 65816 NOP ($EA) +# +runbrk: assemble + x65emu 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/src/test816.asm b/src/test816.asm index 9de3f44..fb9eb1e 100644 --- a/src/test816.asm +++ b/src/test816.asm @@ -25,6 +25,8 @@ reset: xba ; wai + nop + ora $12,s lda ($23) pea $1234 From 599ce2e07a7854e4206fc11fa390c681eadd7282 Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Sun, 24 Aug 2025 18:21:23 +0100 Subject: [PATCH 02/10] Tweak to makefile --- cli/minimal/Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cli/minimal/Makefile b/cli/minimal/Makefile index 50ec943..a735f6c 100644 --- a/cli/minimal/Makefile +++ b/cli/minimal/Makefile @@ -4,7 +4,13 @@ # # ************************************************************************************** -EMULATOR = x65emu +# +# Path / Name of emulator. +# +EMULATOR = emu_linux_x64 +# +# 64tass optios. +# ASMOPTS = -b -w -x # @@ -16,10 +22,10 @@ assemble: # Run program without break. # run: assemble - x65emu file=test.xex + x65emu -q file=test.xex # # Run program and break on 65816 NOP ($EA) # runbrk: assemble - x65emu file=test.xex break=EA + x65emu -q file=test.xex break=EA From e0c642089d837e86884d2eea83e2fcad1d9a34d7 Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Mon, 25 Aug 2025 08:32:55 +0100 Subject: [PATCH 03/10] Text working --- cli/text/Makefile | 31 +++++++++ cli/text/os816/cgia.inc | 97 +++++++++++++++++++++++++++++ cli/text/os816/dspl.asm | 98 +++++++++++++++++++++++++++++ cli/text/os816/ria.inc | 96 ++++++++++++++++++++++++++++ cli/text/text.asm | 135 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 457 insertions(+) create mode 100644 cli/text/Makefile create mode 100644 cli/text/os816/cgia.inc create mode 100644 cli/text/os816/dspl.asm create mode 100644 cli/text/os816/ria.inc create mode 100644 cli/text/text.asm 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 #dspl_chargen ; high byte + sta RIA_Stack + lda # Date: Mon, 25 Aug 2025 17:45:25 +0100 Subject: [PATCH 04/10] Tidied up text display --- cli/text/text.asm | 128 ++++++++++++++++++---------------------------- cli/text/text.inc | 32 ++++++++++++ 2 files changed, 82 insertions(+), 78 deletions(-) create mode 100644 cli/text/text.inc diff --git a/cli/text/text.asm b/cli/text/text.asm index f05c759..8a0f4fc 100644 --- a/cli/text/text.asm +++ b/cli/text/text.asm @@ -4,6 +4,17 @@ ; ; ************************************************************************************** + textWidth = 48 + textHeight = 30 + textSize = textWidth * textHeight + + dispCharacters = $4000 + dispForeground = dispCharacters + $0800 + dispBackground = dispCharacters + $1000 + dispFontData = dispCharacters + $1800 + + .include "text.inc" + .autsiz ; generate code based on last REP/SEP ; ; Start code at $200 (e.g. above zero page and stack) @@ -15,44 +26,6 @@ ProgramStart = $200 .word ProgramStart ; first byte to copy .word ProgramEnd-1 ; last byte to copy -dspl_text_buffer = $4000 -dspl_fg_buffer = dspl_text_buffer + $1000 -dspl_bg_buffer = dspl_fg_buffer + $1800 -dspl_chargen = dspl_text_buffer + $2000 - -dspl_buffer_width = 48 -dspl_buffer_height = 30 -dspl_buffer_size = dspl_buffer_width * dspl_buffer_height - -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 - -RIA = $FFC0 -RIA_Stack = RIA + $30 -RIA_Op = RIA + $31 - -CGIA = $FF00 -CGIA_Mode = CGIA -CGIA_Planes = CGIA+$30 -CGIA_Offset0 = CGIA+$38 -CGIA_Plane0 = CGIA+$40 -CGIAP_RowHeight = 2 - -RIA_API_GET_CHARGEN = $10 ; ; This is the main code block. @@ -62,67 +35,65 @@ RIA_API_GET_CHARGEN = $10 sep #$30 ; 8 bit AXY - ; initialize CGIA - stz CGIA_Mode - stz CGIA_Planes - ; clear all CGIA registers - ldx #$7F + stz CGIA_Mode ; initialize CGIA + stz CGIA_Planes + + + ldx #$7F ; clear all CGIA registers _ClearCGIA: stz CGIA,x dex bpl _ClearCGIA - - ; fetch character generator from RIA firmware - phb + phb ; fetch character generator from RIA firmware pla - sta RIA_Stack ; bank address - lda #>dspl_chargen ; high byte - sta RIA_Stack - lda #dispFontData ; high byte + sta RIA_Stack + lda # Date: Mon, 8 Sep 2025 08:59:44 +0100 Subject: [PATCH 05/10] Update cli/minimal/Makefile Co-authored-by: Tomasz Sterna --- cli/minimal/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/minimal/Makefile b/cli/minimal/Makefile index a735f6c..f2c34fe 100644 --- a/cli/minimal/Makefile +++ b/cli/minimal/Makefile @@ -22,7 +22,7 @@ assemble: # Run program without break. # run: assemble - x65emu -q file=test.xex + $(EMULATOR) -q file=test.xex # # Run program and break on 65816 NOP ($EA) From acf58c3951d12e5345d53ae3201202b7d60ea23f Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Mon, 8 Sep 2025 08:59:54 +0100 Subject: [PATCH 06/10] Update cli/minimal/Makefile Co-authored-by: Tomasz Sterna --- cli/minimal/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/minimal/Makefile b/cli/minimal/Makefile index f2c34fe..80baa8b 100644 --- a/cli/minimal/Makefile +++ b/cli/minimal/Makefile @@ -28,4 +28,4 @@ run: assemble # Run program and break on 65816 NOP ($EA) # runbrk: assemble - x65emu -q file=test.xex break=EA + $(EMULATOR) -q file=test.xex break=EA From 1ce60a46f949cb34cfc3f4170cdd9736f77c6353 Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Mon, 8 Sep 2025 09:05:25 +0100 Subject: [PATCH 07/10] Update .gitignore --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index 47def2f..8dc14ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,2 @@ /build/ /.cache/ -*.lst -*.xex -dap.log -65816 \ No newline at end of file From bd014286cefc14bdb90723325ac1915c33e12185 Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Mon, 8 Sep 2025 09:06:16 +0100 Subject: [PATCH 08/10] Update test816.asm --- src/test816.asm | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test816.asm b/src/test816.asm index fb9eb1e..59e629e 100644 --- a/src/test816.asm +++ b/src/test816.asm @@ -25,7 +25,6 @@ reset: xba ; wai - nop ora $12,s lda ($23) From 31e81ec58fb83b0f7d5c3fd78dccda3498f4f678 Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Mon, 8 Sep 2025 09:06:47 +0100 Subject: [PATCH 09/10] Update test816.asm --- src/test816.asm | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test816.asm b/src/test816.asm index 59e629e..93946d4 100644 --- a/src/test816.asm +++ b/src/test816.asm @@ -24,7 +24,6 @@ reset: lda #0 xba ; wai - ora $12,s lda ($23) From 3580eab6268951f5261de75d7314763e9edff295 Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Mon, 8 Sep 2025 09:07:56 +0100 Subject: [PATCH 10/10] Update test816.asm --- src/test816.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test816.asm b/src/test816.asm index 93946d4..9de3f44 100644 --- a/src/test816.asm +++ b/src/test816.asm @@ -24,7 +24,7 @@ reset: lda #0 xba ; wai - + ora $12,s lda ($23) pea $1234