diff --git a/wip-dicander/STARTUP.s b/wip-dicander/STARTUP.s deleted file mode 100755 index ce821b9..0000000 --- a/wip-dicander/STARTUP.s +++ /dev/null @@ -1,82 +0,0 @@ -.scope STARTUP -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- -;;Settings positions -CR1 = $d011; ;Graphic settings -VIC_bank_settings = $DD00 ; Vic position -Screen_RAM_settings =$D018 ;Screen RAM position relative to VIC - -;;########## VIC_BANK ################ -;;# BITMAP | $4000 -$5F3F -;;# Unused? | $5F3F - $6000 -;;# SCREAN RAM (color) | $6000 -$63E7 -;;# Unused? | $63E8 - $7FFF -;;# -;;#################################### - -;;Memory positions -VIC_bank = $4000 -VIC_bank_end = VIC_bank + $3FFF - -Bitmap = VIC_bank -Bitmap_end = $5F3F - -Screen_RAM = $2000 + VIC_bank -Screen_RAM_end = Screen_RAM + $03E7 - -Character_generator_ROM = $D000 - -;;Free up memory -;;https://www.c64-wiki.com/wiki/Bank_Switching -;; -;;Set graphic mode [Standard bitmap mode] -;;https://www.c64-wiki.com/wiki/Standard_Bitmap_Mode -LDA #%10111111 ; ECM = False Extended color mode -AND CR1 -STA CR1 - -LDA #%00100000; BMM = True Bitmap mode -ORA CR1 -STA CR1 - -;;Set VIC bank to bank 1 -;;https://www.c64-wiki.com/wiki/VIC_bank -LDA #%11111110 ;bit_0 = False -AND VIC_bank_settings -STA VIC_bank_settings - -LDA #%00000010; bit_1 = True -ORA VIC_bank_settings -STA VIC_bank_settings - -;;Set Scren-RAM to offset 8 ;https://www.c64-wiki.com/wiki/53272 (offset is 8k byte = 1024*8-ich) -LDA #%10001111 ; bit_6 =bit_5=bit_4 = Falsw -AND Screen_RAM_settings -STA Screen_RAM_settings - -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 -Mov_16 >B_start, VIC_bank -Mov_16 >B_end, $5f3f -LDA #$00 -jsr memset - - -;;Sets the screen color to black and white -Mov_16 >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 -AND $0001 -STA $0001 -;https://www.c64-wiki.com/wiki/Bank_Switching -;Disable IO, CHAREN =0 -;LDA #%11111011 -;AND $0001 -;STA $0001 -.endscope diff --git a/wip-dicander/macros/16bitarithmetic.s b/wip-dicander/macros/16bitarithmetic.s deleted file mode 100755 index 0f41cc9..0000000 --- a/wip-dicander/macros/16bitarithmetic.s +++ /dev/null @@ -1,140 +0,0 @@ -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- - -;; A file containing 16-bit macro arithmatic. -;; You may add ,! ass a 5:th parameter to skipp flagg clearing. -;; This will make it run faster but will have unintended behavior. - -;;Se below for some fast 16bit logic -;;http://6502.org/tutorials/compare_beyond.html - -;; Addition always uses the A register -;; a = a + b -.macro Add_16 a_low, a_hi, b_low, b_hi, fast_unsafe -;; IF to run it fast -.ifblank fast_unsafe - CLC -.endif -.if .not .match ({b_low}, a) - LDA b_low -.endif ;;untested - ADC a_low - STA a_low -.if .match ({b_hi}, x) ;;Untested - TXA -.else - LDA b_hi -.endif - ADC a_hi - STA a_hi -.endmacro - - -;; Subtraction uses always uses A register -;; a = a - b -.macro Sub_16 a_low, a_hi, b_low, b_hi, fast_unsafe -;; IF to run it fast -.ifblank fast_unsafe - SEC -.endif -;; if b_low = A and b_hi =A -.if .match({b_low}, a) .and .match({b_hi}, a) ;;untested - .LOCAL rewrite - .LOCAL rewrite2 - STA rewrite +1 - STA rewrite2 + 1 - LDA a_low - rewrite: - SBC #b_low - STA a_low - LDA a_hi - rewrite2: - SBC #b_hi - STA a_hi -;; if b_low = A -.elseif .match({b_low}, a) ;;untested - .LOCAL rewrite - STA rewrite +1 - LDA a_low - rewrite: - SBC #b_low - STA a_low - LDA a_hi - SBC b_hi - STA a_hi -.elseif .match({b_hi}, a) ;;untested - .LOCAL rewrite - STA rewrite +1 - LDA a_low - SBC b_low - STA a_low - LDA a_hi - rewrite: - SBC #b_hi - STA a_hi -.else - LDA a_low - SBC b_low - STA a_low - LDA a_hi - SBC b_hi - STA a_hi -.endif -.endmacro - -;; Subtraction uses always uses A register -;; a = (A, a_hi) - b -.macro Sub_16_A a_low, a_hi, b_low, b_hi, fast_unsafe -;; IF to run it fast -.ifblank fast_unsafe - SEC -.endif - SBC b_low - STA a_low - LDA a_hi - SBC b_hi - STA a_hi -.endmacro - - -;; Multiplication of 2 -;; a = a*2 -.macro Mult_16 low_, hi_, NOT_ROL -;; IF NOT_ROL -.ifblank fast_unsafe - ASL low_ - ROL hi_ -.else - ROL low_ - ROL hi_ -.endif -.endmacro - -.macro Mov_16 a_low, a_hi, b_low, b_hi - LDA b_low - STA a_low - LDA b_hi - STA a_hi -.endmacro - -;;http://www.6502.org/tutorials/compare_beyond.html -;;Larger then operation, uses the A register -;;IF a < b then: jump to label -; C =0 if jump to LABEL -.macro Lag_16 a_low, a_hi, b_low, b_hi, label - .LOCAL LABEL - LDA a_hi - CMP b_hi - BCC label - BNE LABEL - LDA a_low -.if .match ({b_low}, a) - .LOCAL next - STY next +1 -next: - CMP #$ff -.else - CMP b_low -.endif - BCC label - LABEL: -.endmacro diff --git a/wip-dicander/macros/timer.s b/wip-dicander/macros/timer.s deleted file mode 100644 index 92c7059..0000000 --- a/wip-dicander/macros/timer.s +++ /dev/null @@ -1,34 +0,0 @@ -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- - -;; Max 0.9s -;; Exempel i kod: -;; -;; time_start -;; ... -;; time_stop -;; -;; Läs tiden genom att undersöka värdet i $f1 (BSD-format) -time = $f1 -.macro time_start - PHA - LDA $DC08 ; Bit 0..3: Tenth seconds in BCD-format, others may be 0 or 1 - ;;;;Clear all time data and set time =1. - AND #%11110000 - STA $DC08 - INC $DC08 - LDA $DC08 - ;;Time is only at bit 0 ..3 - AND #%00001111 - STA time - PLA -.endmacro - -.macro time_stop - PHA - LDA $DC08 ; Bit 0..3: Tenth seconds in BCD-format, others may be 0 or 1 - AND #%00001111 - SEC - SBC time - STA time - PLA -.endmacro diff --git a/wip-dicander/routines/line/line.s b/wip-dicander/routines/line/line.s deleted file mode 100644 index 5b656e8..0000000 --- a/wip-dicander/routines/line/line.s +++ /dev/null @@ -1,47 +0,0 @@ -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- - -.proc line; X_pos =< X_end skall alltid gälla - .include "line.inc" - ; dx_ = $0c - ; dy_ = $06 - ;;dx - SEC - LDA X_end - SBC X_pos - 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 - BCC down ;normal Y_pos < Y_end -up:; Y_pos > Y_end - STA dy - CMP dx - BCC shallow; dy < dx -steep: - jsr line_up_inv - RTS -shallow: ;dy =< dx - lda dx - jsr line_up - RTS -down: - EOR #$ff ; Fix bit underflow - STA dy - CMP dx - BCC shallow_; dy < dx -steep_: - jsr line_down_inv - RTS -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 diff --git a/wip-dicander/routines/line/line_down.s b/wip-dicander/routines/line/line_down.s deleted file mode 100644 index e90ab7a..0000000 --- a/wip-dicander/routines/line/line_down.s +++ /dev/null @@ -1,116 +0,0 @@ -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- - -;;drawing line from 2 cordinates -;;# (X_pos, Y_pos) # -;;# * # -;;# * # -;;# * # -;;# (X_end, Y_end) # -;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg! - -.proc line_down - - .include "line.inc"; Defines memory positions, ex X_pos - - ;;We need to clear this memory - LDA #$00 - STA V - Mult_16 >V, dy_2, dy_2 = dy (same address) - - ;; This is an Bresenham's line algorithm, se wikipedia bellow. - ;;https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm - ;; We need to compute the Value D = 2*dy - dx, - ;; but it may be or get negative. - ;; IN the loop we may set D = D -V - ;; Because math D needs to be at least >=V. - ;; V_max = %00000001 11111111 - ;; We therefor need to add this offset to V 00000001 11111111 - ;; and to its branch logic later in the loop. - - ;;D = 2*dy - dx + 2*255 - Mov_16 >D, dy_2, D, D, dy_2 - LDA >dy_2 - STA case_2 +1 - ;; Modifies LDA V - LDA >V - STA case_1 +1 - ;; Modifies SBC btp_mem_pos), Y - STA (>btp_mem_pos), Y -increment_pixel_x: - LSR byte_to_paint ; Rotates the pixel one bit to the left ON THE SCREEN. - BCC increment_pixel_x_end; We need to move to the next chunk -move_8px_left: - ;; Next chunk is 8 addresses away. Look in pixel_draw for more detail. - ;; -8. - ;; C = 1 therefore you se 07 - Add_16 >btp_mem_pos, D, D - Sub_16_A >D, V, # C=1 - LDY #$00 - ;; Switch to chunk bellow - ; C = 1 - ; So we subtract #$3F, #$01 +C - Add_16 >btp_mem_pos, D, dy_2, #V - Mult_16 >V, dx_2, D, dx_2, D, D, dx_2 - STA case_2 +1 - LDA V - STA case_1 +1 - LDA btp_mem_pos), Y - STA (>btp_mem_pos), Y -increment_y_pos: - INY - CPY #$08 - BNE increment_y_pos_end -move_8px_down: - LDY #$00 - Add_16 >btp_mem_pos, D, D, V, #btp_mem_pos, D, dx_2, #B_start, VIC_bank - Mov_16 >B_end, $5f3f - LDA #$00 - jsr memset - - - LDA #$00 - STA X_pos_ - LDA #$60 - STA Y_pos_ - LDA #$ff - STA X_end - LDA #$0 - STA Y_end -@loop: - LDA Y_pos_ - STA Y_pos - LDA X_pos_ - STA X_pos - jsr line - INC Y_end - LDA Y_end - CMP #$bb - BEQ end_ - jmp @loop -end_: - jmp exit -.endscope diff --git a/wip-dicander/routines/line/line_test_time.s b/wip-dicander/routines/line/line_test_time.s deleted file mode 100644 index 7006dde..0000000 --- a/wip-dicander/routines/line/line_test_time.s +++ /dev/null @@ -1,49 +0,0 @@ -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- -.scope line_test_time - .include "line.inc" - - ;;START TIME HERE - - ;;for testing stuff - Y_pos_ = $0D - X_pos_ = $0E - Y_end_ = $10 - X_end_ = $11 - LDA #$00 - STA X_pos_ - LDA #$30 - STA Y_pos_ - LDA #$ff - STA X_end - LDA #$30 - STA Y_end - - -@loop:;; mem f1 - LDA Y_pos_ - STA Y_pos - LDA X_pos_ - STA X_pos - - jsr line - INC Y_end - LDA Y_end - CMP #$50 - BEQ end__ - jmp @loop -end__: - ;;Lets cleer bitmap - B_start = $FCFD - B_end = $FEFF - VIC_bank = $4000 - VIC_bank_end = VIC_bank + $3FFF - ;;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 - Mov_16 >B_start, VIC_bank - Mov_16 >B_end, $5f3f - LDA #$00 - jsr memset - - - jmp exit - -.endscope diff --git a/wip-dicander/routines/line/line_up.s b/wip-dicander/routines/line/line_up.s deleted file mode 100644 index 3296bd3..0000000 --- a/wip-dicander/routines/line/line_up.s +++ /dev/null @@ -1,78 +0,0 @@ -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- - -;;drawing line from 2 cordinates -;;# * (X_end, Y_end) # -;;# # -;;# * # -;;# * # -;;# (X_pos, Y_pos) # -;; -;;NOTE THAT X_pos <= X_end, Y_pos >= Y_end. Max 45deg! - -.proc line_up - ;; Look at line_down for referense - .include "line.inc"; Defines memory positions, ex X_pos - - LDA #$00 - STA V - Mult_16 >V, dy_2, D, dy_2, D, D, dy_2 - STA case_2 +1 - LDA V - STA case_1 +1 - LDA btp_mem_pos, btp_mem_pos), Y - STA (>btp_mem_pos), Y -increment_pixel_x: - LSR byte_to_paint - BCC increment_pixel_x_end -move_8px_left: - Add_16 >btp_mem_pos, D, D, V, #btp_mem_pos, D, dy_2, #) Y_end, X_pos <= X_end. Min 45deg! - -.proc line_up_inv - ;; Look at line_down for referense - .include "line.inc"; Defines memory positions, ex X_pos - - LDA #$00 - STA V - Mult_16 >V, dx_2, D, dx_2, D, D, dx_2 - STA case_2 +1 - LDA V - STA case_1 +1 - LDA btp_mem_pos), Y - STA (>btp_mem_pos), Y -decrement_y_pos: - DEY - CPY #$ff - BNE decrement_y_pos_end -move_8px_up: - LDY #$07 - Sub_16>btp_mem_pos, D, D, V, #btp_mem_pos, D, dx_2, #B_start - Sub_16 >A_start, B_start, #$00 - - ;;Lets move B_start lover-nibble to Y - LDY >B_start - LDA #$00 - STA >B_start -loop: - Lag_16 >B_end, B_start), Y - STA (>A_start), Y - ;Tip save time by counting downward, fast to check if Y ==0 // hugo - INY - TYA - CMP #$ff - BNE loop - ;; Fix overflow - LDY #$00 - INC B_start, $D000 - ;#### TEMP INIT DATA #### - Mov_16 >B_end, ($D000 +$1F3F) - LDA #$10 - STA code - LDA #$10 - STA X_pos - STA Y_pos - - VIC_bank = $4000 - VIC_bank_end = VIC_bank + $3FFF - Mov_16 >A_start, VIC_bank - ;We first need to clear some memory - ;Mov_16 >A_end, >A_end, #<(VIC_bank+100), #>(VIC_bank +100) - LDA #$00 - JSR memcpy - STA B_start ,X) - - Add_16 >B_start, B_start - CMP >B_end - BEQ test - jmp loop -test: - LDA B_start, X) - RTS -.endproc diff --git a/wip-dicander/routines/memory/pixel_draw.s b/wip-dicander/routines/memory/pixel_draw.s deleted file mode 100755 index 2138d70..0000000 --- a/wip-dicander/routines/memory/pixel_draw.s +++ /dev/null @@ -1,83 +0,0 @@ -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- - -;;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 - .include "mem.inc" - Bitmap = $4000 - Bitmap_end = $5F3F - ;; X = X_pos (mod 8) - LDA >X_pos ; X (mod 8) - AND #%00000111 - TAX - - ;;Store pixel in byte_to_paint - LDA #%10000000 - INX -@shift_btp: ;; check out SMB instruction here! //Hugo - DEX - BEQ end__;X=0 end this - CLC - ROR A - jmp @shift_btp -end__: - STA byte_to_paint - - ;;FIND THE POSITION IN MEMORY TO WRITE PIXEL - ;; + + + + + > X - ;; + - ;; + - ;;\/ - ;; Y - ;; - - ;;pos = x_offset - LDA #%11111000 - AND >X_pos - STA >btp_mem_pos - - LDA C - STA >B - LDA #$00 - STA C, C, C, B, C, C, C, btp_mem_pos, C, btp_mem_pos, Bitmap, ! - - ;;Let draw some stuff - LDA byte_to_paint ;; note that both bytes are used! - ORA (>btp_mem_pos), Y - STA (>btp_mem_pos), Y - RTS -.endproc diff --git a/wip-dicander/routines/text/char_draw.s b/wip-dicander/routines/text/char_draw.s deleted file mode 100644 index 65ed67a..0000000 --- a/wip-dicander/routines/text/char_draw.s +++ /dev/null @@ -1,83 +0,0 @@ -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- -;; petski: https://www.c64-wiki.com/wiki/File:ASCII-Codes.gif -;;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 char_draw - Character_generator_ROM = $D000 - Y_pos_offset = $F9F8 ;Reuses from Y_pos - X_pos_offset = $FAF7 - X_pos = $FA - Y_pos = $F9 - charset = $FB - code = $FE - petski_position = $FEFF ;reuses code:s memory - screen_position = $FCFD - - ;#### TEMP INIT DATA #### - LDA #$10 - STA code - LDA #04 - STA X_pos - LDA #02 - STA Y_pos - - ;;Do arithimatic to know where to read and write bytes. - initial: - ;We first need to clear some memory - LDA #$00 - STA petski_position, petski_position, petski_position, Character_generator_ROM, ! - - ;;Calculate screen_position to use - Mov_16 >screen_position, VIC_bank - - ;; Add the X_pos has a offset multiplier of *8 because 1 chunk = 8 addresses - ;; *8 - Mult_16 >X_pos_offset, X_pos_offset, X_pos_offset, screen_position, Y_pos_offset, Y_pos_offset, Y_pos_offset, Y_pos_offset, Y_pos_offset, Y_pos_offset, Y_pos_offset, Y_pos_offset, Y_pos_offset, screen_position, Y_pos_offset, petski_position), Y - STA (>screen_position), Y - DEY - BNE @loop - LDA (>petski_position), Y - STA (>screen_position), Y - RTS -.endproc diff --git a/wip-dicander/run.sh b/wip-dicander/run.sh deleted file mode 100755 index fe7c135..0000000 --- a/wip-dicander/run.sh +++ /dev/null @@ -1,10 +0,0 @@ -# !/bin/bash -killall x64sc - -#Note that program start at $080D -cl65 -o file.prg -u __EXEHDR__ -t c64 -C c64-asm.cfg -l file.list source.s \ -&& nohup flatpak run net.sf.VICE -windowypos 0 -windowxpos 960 -windowwidth 945 -windowheight 720 file.prg /dev/null & - -sleep 2 -rm source.o -rm file.prg diff --git a/wip-dicander/source.s b/wip-dicander/source.s deleted file mode 100755 index 19073bc..0000000 --- a/wip-dicander/source.s +++ /dev/null @@ -1,67 +0,0 @@ -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- -.debuginfo + ; Generate debug info -;;Macros -.include "macros/16bitarithmetic.s" -;;inc files -.include "routines/memory/mem.inc" -;;Code to run -.include "STARTUP.s" -;.include "routines/line/line_test_time.s" -;;.include "routines/memory/memcpy_test.s" -;.include "fillscreen.s" -;Hacky hardcoding. I pick FC and FD to contain the 16 bit offset to the screen -LDA #$40 ;Remember kids, C64 is a little endian computer. Why, why why! Big endian makes more sense! -STA $FD ;THis means that the bitmap starts at $4000 -LDA #$00 -LDX #$60 -STA $FC - -mainloop: -;fill screen with white pixels -LDY #$00 -LDA #%10000000 ; Start out with setting the leftmost pixel to white in every byte in the bitmap -STA $FF ;$FF contains the pattern we are writing to part if the bitmap memory -STA $FE ;$FE conatins the most recent bit/pixel we are adding -;The idea is now to bitshift this to the right, until A is 0. When this happens it is time to update which byte we are working on -pixel_setting_loop: -LDA $FF -STA ($FC),Y -LDA $FE ;FE contains the most recent bit/pixel we are adding -LSR a -BNE more_pixels_in_byte -INC $FC -; if this overflows -BNE not_incrementing_other_byte -INC $FD -CPX $FD -; if the carry flag is zero, branch -BCC done_pixels -not_incrementing_other_byte: -LDA #%10000000 -STA $FE -STA $FF -more_pixels_in_byte: -STA $FE ;$FE conatins the most recent bit/pixel we are adding -ORA $FF ;Add the previous pixels. -STA $FF -JMP pixel_setting_loop -done_pixels: -;check is somebody has pressed space and if so exit, code blatantly stolen from Duuqnd -LDX #%01111111 -LDY #%00010000 -LDA #$ff -STA $DC02 -LDA #$00 -STA $DC03 -STX $DC00 -TYA -AND $DC01 -;Check if A is 0 -BEQ die -jmp mainloop -die: -;.include "routines/line/line.s" -;.include "routines/memory/pixel_draw.s" -.include "routines/memory/memset.s" -;.include "routines/memory/memcpy.s" -