diff --git a/wip-hugo/STARTUP.s b/wip-hugo/STARTUP.s index c4c6299..dea8caa 100755 --- a/wip-hugo/STARTUP.s +++ b/wip-hugo/STARTUP.s @@ -1,3 +1,5 @@ +.scope STARTUP +;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;Settings positions CR1 = $d011; ;Graphic settings VIC_bank_settings = $DD00 ; Vic position @@ -55,35 +57,18 @@ LDA #%10000000; bit_1 = True ORA Screen_RAM_settings STA Screen_RAM_settings - ;;Paint the bitmap black. More bitmap: https://www.c64-wiki.com/wiki/53272, https://www.c64-wiki.com/wiki/Screen_RAM#Moving_of_screen_RAM -LDA #>VIC_bank -STA $FC -LDA #$5f3f -STA $FE -LDA #<$5f3f -STA $FD - -LDA #$0 +Mov_16 >B_start, VIC_bank +Mov_16 >B_end, $5f3f +LDA #$00 jsr memset + ;;Sets the screen color to black and white -LDA #>Screen_RAM -STA $FC -LDA #Screen_RAM_end -STA $FE -LDA #B_start, Screen_RAM +Mov_16 >B_end, Screen_RAM_end LDA #%11110000 jsr memset - SEI ;Disable interups (not all) ;;Disable BASIC ROM mohahaha LDA #%11111110 @@ -94,3 +79,4 @@ STA $0001 LDA #%11111011 AND $0001 STA $0001 +.endscope diff --git a/wip-hugo/routines/line/line.inc b/wip-hugo/routines/line/line.inc index ba7316b..1965bb4 100644 --- a/wip-hugo/routines/line/line.inc +++ b/wip-hugo/routines/line/line.inc @@ -3,6 +3,7 @@ ;;Not values but register position in memory X_end = $04 Y_end = $05 + ;;These come from mem.inc X_pos = $FC Y_pos = $FB dx = $0c @@ -11,6 +12,6 @@ dx_2 = $0cF3 V = $0809 D = $0a0b - ;;These are also used in pixel_draw. Look there to find out more - byte_to_paint = $FE ;Byte with one 1 that corasponds to a pixel. - btp_mem_pos =$494A; byte to paint memory position ;Position of byte on screen + ;;These come from mem.inc + byte_to_paint = $FE ;Byte with one 1 that corisponds to a pixel. + btp_mem_pos =$F9FA; byte to paint memory position ;Position of byte on screen diff --git a/wip-hugo/routines/line/line.s b/wip-hugo/routines/line/line.s index fc1c272..15f05df 100644 --- a/wip-hugo/routines/line/line.s +++ b/wip-hugo/routines/line/line.s @@ -1,38 +1,37 @@ ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- .proc line; X_pos =< X_end skall alltid gälla - ;; note that these have same adresses as stuff in line.inc - ;; This should be used as a optimisation in the future - dx = $0c - dy = $06 + .include "line.inc" + dx_ = $0c + dy_ = $06 ;;dx SEC LDA X_end SBC X_pos - STA dx + STA dx_ BCC dx_no_underflow;; X_end >= X_pos EOR #$ff ; Fix bit underflow dx_no_underflow: SEC LDA Y_pos SBC Y_end - STA dy + STA dy_ BCC down ;normal Y_pos < Y_end up:; Y_pos > Y_end - STA dy - CMP dx + STA dy_ + CMP dx_ BCC shallow; dy < dx steep: jsr line_up_inv RTS shallow: ;dy =< dx - lda dx + lda dx_ jsr line_up RTS down: EOR #$ff ; Fix bit underflow - STA dy - CMP dx + STA dy_ + CMP dx_ BCC shallow_; dy < dx steep_: ;LDA dx @@ -42,8 +41,9 @@ steep_: shallow_: ;dy < dx jsr line_down RTS + + .include "line_down.s" + .include "line_down_inv.s" + .include "line_up.s" + .include "line_up_inv.s" .endproc -.include "line_down.s" -.include "line_down_inv.s" -.include "line_up.s" -.include "line_up_inv.s" diff --git a/wip-hugo/routines/line/line_test.s b/wip-hugo/routines/line/line_test.s index 03e7b1d..67e67f3 100644 --- a/wip-hugo/routines/line/line_test.s +++ b/wip-hugo/routines/line/line_test.s @@ -1,5 +1,5 @@ ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- - +.scope line_test .include "line.inc" ;;for testing stuff Y_pos_ = $0D @@ -46,17 +46,13 @@ end__: end: ;;Long lines ;;Lets cleer bitmap - LDA #>VIC_bank - STA $FC - LDA #$5f3f - STA $FE - LDA #<$5f3f - STA $FD - - LDA #$0 + B_start = $FCFD + B_end = $FEFF + VIC_bank = $4000 + VIC_bank_end = VIC_bank + $3FFF + Mov_16 >B_start, VIC_bank + Mov_16 >B_end, $5f3f + LDA #$00 jsr memset LDA #$00 @@ -80,5 +76,4 @@ end: jmp @loop end_: jmp exit -.include "line.s" -.include "macros/" +.endscope diff --git a/wip-hugo/routines/line/line_test_time.s b/wip-hugo/routines/line/line_test_time.s index 7a11fc5..87b56db 100644 --- a/wip-hugo/routines/line/line_test_time.s +++ b/wip-hugo/routines/line/line_test_time.s @@ -1,5 +1,5 @@ ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- - +.scope line_test_time .include "line.inc" ;;START TIME HERE @@ -33,6 +33,10 @@ jmp @loop end__: ;;Lets cleer bitmap + B_start = $FCFD + B_end = $FEFF + VIC_bank = $4000 + VIC_bank_end = VIC_bank + $3FFF LDA #>VIC_bank STA $FC LDA #A_start, VIC_bank ;We first need to clear some memory ;Mov_16 >A_end, >A_end, #<(VIC_bank+100), #>(VIC_bank +100) @@ -29,3 +25,4 @@ memcpy_test: JSR memcpy STA B_start ,X) - Add_16 >Address_start, B_start, Address_start - CMP >Address_end + LDA >B_start + CMP >B_end BEQ test jmp loop test: - LDA B_start, X) RTS .endproc diff --git a/wip-hugo/routines/memory/pixel_draw.s b/wip-hugo/routines/memory/pixel_draw.s index 9dfe791..2138d70 100755 --- a/wip-hugo/routines/memory/pixel_draw.s +++ b/wip-hugo/routines/memory/pixel_draw.s @@ -3,12 +3,9 @@ ;;Screen print. Draws a pixel at a specified position. ;; Destroys A X Y .proc pixel_draw; Draws a pixel at [Y = FB , X = FC, FD]. Y = 0 - 320, X= 0 - 200 - Y_pos = $FB - X_pos = $FCFD - byte_to_paint = $FE - btp_mem_pos =$494A; byte to paint memory position - C = $7071 - B =$7273 + .include "mem.inc" + Bitmap = $4000 + Bitmap_end = $5F3F ;; X = X_pos (mod 8) LDA >X_pos ; X (mod 8) AND #%00000111 diff --git a/wip-hugo/routines/text/char_draw.s b/wip-hugo/routines/text/char_draw.s index cc258c6..65ed67a 100644 --- a/wip-hugo/routines/text/char_draw.s +++ b/wip-hugo/routines/text/char_draw.s @@ -5,6 +5,7 @@ ;; And prints it ON X_pos, Y_pos ;; Note that this is the real positions divided by 8 .proc char_draw + Character_generator_ROM = $D000 Y_pos_offset = $F9F8 ;Reuses from Y_pos X_pos_offset = $FAF7 X_pos = $FA diff --git a/wip-hugo/source.s b/wip-hugo/source.s index 79b7b72..324ebf3 100755 --- a/wip-hugo/source.s +++ b/wip-hugo/source.s @@ -1,15 +1,16 @@ +;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- .debuginfo + ; Generate debug info +;;Macros .include "macros/16aritmatic.s" -.include "macros/timer.s" - +;;inc files +.include "routines/memory/mem.inc" +;;Code to run .include "STARTUP.s" -.include "routines/line/line_test_time.s" -;jsr char_draw -;;This is used by .s files to terminate nicely without reading includes at the end! +;.include "routines/line/line_test_time.s" +.include "routines/memory/memcpy_test.s" exit: jmp exit - -.include "routines/text/char_draw.s" -.include "routines/memory/memset.s" +.include "routines/line/line.s" .include "routines/memory/pixel_draw.s" +.include "routines/memory/memset.s" .include "routines/memory/memcpy.s"