From 92b5ee133abee25dff631c3955b80da221c02682 Mon Sep 17 00:00:00 2001 From: mc78 Date: Wed, 28 Aug 2024 13:07:00 +0200 Subject: [PATCH] Fixed imports and usage of deprecated vic and cia register names in set_viewport.s --- libsrc/c64/set_viewport.s | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libsrc/c64/set_viewport.s b/libsrc/c64/set_viewport.s index 48ca312d3..9d05120f2 100644 --- a/libsrc/c64/set_viewport.s +++ b/libsrc/c64/set_viewport.s @@ -1,44 +1,44 @@ ; -; Oliver Schmidt, 16.8.2018 +; Stefan 'MonteCarlos' Andree, 27.08.2024 ; ; int __fastcall__ set_viewport (uint8_t scr_hi, uint8_t chr_hi); ; - .include "time.inc" .include "c64.inc" - .importzp sreg, ptr1 - .import pushax, pusheax, ldax0sp, ldeaxidx - .import tosdiveax, incsp3, return0 - .import TM, load_tenth - + .importzp sp, tmp1, tmp2 + .import incsp1 + .export _set_viewport ;---------------------------------------------------------------------------- .code .proc _set_viewport - sta tmp1 ; chr_hi - ldy #0 + ; on input, a contains chr_hi and stack contains scr_hi + + sta tmp1 ; save chr_hi for later + ldy #0 ; scr_hi stack offset eor (sp), y ; eor scr_hi with chr_hi to determine VIC bank compliance + and #$c0 sec bne @return ; If the upper two bits do not coincide, then the screen and char would be in different VIC banks - - sty tmp2 ; store bank bits temporarily, here - lsr tmp1 ; lsr hi-byte into correct bit position for VIC_ADDR (0x08 -> 0x02, 0x10 -> 0x04 ...) + + sty tmp2 ; store bank bits temporarily, here + lsr tmp1 ; lsr hi-byte into correct bit position for VIC_VIDEO_ADR (0x08 -> 0x02, 0x10 -> 0x04 ...) lsr tmp1 ; The vic bank check prevents doing this directly in an effective manner, beforehand lda (sp), y ; scr_hi - asl ; rol hi-byte into correct bit position for VIC_ADDR (0x04 -> 0x10, 0x08 -> 0x20 ...) + asl ; rol hi-byte into correct bit position for VIC_VIDEO_ADR (0x04 -> 0x10, 0x08 -> 0x20 ...) rol tmp2 ; rol hi-bits into bank bits asl - rol tmp2 ; rol's 0 into carry + rol tmp2 ; rol's 0 into carry which results in returning EXIT_SUCCESS, later ora tmp1 ; combine scr and char bits to the final register value - sta VIC_ADDR + sta VIC_VIDEO_ADR - lda CIA2_pra + lda CIA2_PRA ora #$03 ; prepare for eor eor tmp2 ; EOR bank bits, because in the register the bits are reversed - sta CIA2_pra + sta CIA2_PRA @return: jsr incsp1 ; does not influence carry ; return EXIT_SUCCESS, if clc