From 1d4efe67251ee7f963cbe2b6416a78b4bcbda514 Mon Sep 17 00:00:00 2001 From: hugova Date: Fri, 28 Mar 2025 20:35:58 +0100 Subject: [PATCH] Partialy implement text writing --- wip-hugo/STARTUP.s | 2 ++ wip-hugo/c64-asm_mod.cfg | 20 ------------- wip-hugo/macros/16aritmatic.s | 23 +++++++------- wip-hugo/routines/text/text.s | 56 ++++++++++++++++++++++++++++------- 4 files changed, 60 insertions(+), 41 deletions(-) delete mode 100644 wip-hugo/c64-asm_mod.cfg diff --git a/wip-hugo/STARTUP.s b/wip-hugo/STARTUP.s index dfa07be..c4c6299 100755 --- a/wip-hugo/STARTUP.s +++ b/wip-hugo/STARTUP.s @@ -21,6 +21,8 @@ Bitmap_end = $5F3F Screen_RAM = $2000 + VIC_bank Screen_RAM_end = Screen_RAM + $03E7 +Character_generator_ROM = $D000 + ;;Free upp memory ;;https://www.c64-wiki.com/wiki/Bank_Switching ;; diff --git a/wip-hugo/c64-asm_mod.cfg b/wip-hugo/c64-asm_mod.cfg deleted file mode 100644 index ffe2184..0000000 --- a/wip-hugo/c64-asm_mod.cfg +++ /dev/null @@ -1,20 +0,0 @@ -FEATURES { - STARTADDRESS: default = $0400; -} -SYMBOLS { - __LOADADDR__: type = import; -} -MEMORY { - ZP: file = "", start = $0002, size = $00FE, define = yes; - LOADADDR: file = %O, start = %S - 2, size = $0002; - MAIN: file = %O, start = %S, size = $D000 - %S; -} -SEGMENTS { - ZEROPAGE: load = ZP, type = zp, optional = yes; - LOADADDR: load = LOADADDR, type = ro; - EXEHDR: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = rw; - RODATA: load = MAIN, type = ro, optional = yes; - DATA: load = MAIN, type = rw, optional = yes; - BSS: load = MAIN, type = bss, optional = yes, define = yes; -} diff --git a/wip-hugo/macros/16aritmatic.s b/wip-hugo/macros/16aritmatic.s index 8aca513..a96902d 100755 --- a/wip-hugo/macros/16aritmatic.s +++ b/wip-hugo/macros/16aritmatic.s @@ -37,6 +37,18 @@ STA hi .endmacro +.macro Add_16_A a_low, a_hi, b_hi, fast_unsafe +;; IF to run it fast +.ifblank fast_unsafe + CLC +.endif + ADC a_low + STA a_low + LDA b_hi + ADC a_hi + STA a_hi +.endmacro + ;; Subtraction uses the A register ;; a = a - b .macro Sub_16 a_low, a_hi, b_low, b_hi, fast_unsafe @@ -101,17 +113,6 @@ LABEL: .endmacro - -;.macro Lag_16y a_hi, b_hi,b_low, label -; LDA a_hi -; CMP b_hi -; BCC label -; BNE LABEL -; ;LDA a_low -; CPY b_low -; BCC label -; LABEL: -;.endmacro .macro Lag_16y a_low, a_hi, b_hi, label LDA a_hi CMP b_hi diff --git a/wip-hugo/routines/text/text.s b/wip-hugo/routines/text/text.s index 46bea5f..45c350e 100644 --- a/wip-hugo/routines/text/text.s +++ b/wip-hugo/routines/text/text.s @@ -1,17 +1,53 @@ ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;; petski: https://www.c64-wiki.com/wiki/File:ASCII-Codes.gif -;; d000 +;;https://www.c64-wiki.com/wiki/Character_set +;; Takes in a PETSKI-code in CODE +;; And prints it ON X_pos, Y_pos +;; Note that this is the real positions divided by 8 .proc text - ;; TESTING OF MEMCPY TEMPERARLY HERE BECAUSE IT WILL USE THAT :) - A_start = $FAFB - B_start = $FCFD - B_end = $FEFF + X_pos = $FA + Y_pos = $F9 + charset = $FB + code = $FE + petski_position = $FEFF ;reuses code:s memory + screen_position = $FCFD - Mov_16 >B_start, $D000 - Mov_16 >B_end, ($D000 +$1F3F) + ;#### TEMP INIT DATA #### + LDA #$10 + STA code + LDA #$10 + STA X_pos + STA Y_pos - Mov_16 >A_start, VIC_bank - ;Mov_16 >A_end, >A_end, #<(VIC_bank+100), #>(VIC_bank +100) - JSR memcpy + ;We first need to clear some memory + LDA #$00 + STA petski_position, petski_position, petski_position, petski_position, Character_generator_ROM + + ;;Calculate screen_position to use + Mov_16 >screen_position, VIC_bank + + ;; One character is 8 byte, move these bytes to screen + LDY #$07 +@loop: + LDA (>petski_position), Y + STA (>screen_position), Y + DEY + BNE @loop +hihi: + LDA (>petski_position), Y + STA (>screen_position), Y + jmp hihi RTS .endproc