From 864b0e659bc73c753e4548c69d495727edbe391c Mon Sep 17 00:00:00 2001 From: hugova Date: Thu, 27 Feb 2025 22:04:43 +0100 Subject: [PATCH] Add hugo code --- wip-hugo/README.md | 50 ++++++++++++++ wip-hugo/STARTUP.s | 99 +++++++++++++++++++++++++++ wip-hugo/macros/16aritmatic.s | 48 +++++++++++++ wip-hugo/routines/memory/line_down.s | 81 ++++++++++++++++++++++ wip-hugo/routines/memory/memory_rec.s | 48 +++++++++++++ wip-hugo/routines/memory/pixel_draw.s | 90 ++++++++++++++++++++++++ wip-hugo/run.sh | 4 ++ wip-hugo/source.s | 13 ++++ 8 files changed, 433 insertions(+) create mode 100755 wip-hugo/README.md create mode 100755 wip-hugo/STARTUP.s create mode 100755 wip-hugo/macros/16aritmatic.s create mode 100644 wip-hugo/routines/memory/line_down.s create mode 100755 wip-hugo/routines/memory/memory_rec.s create mode 100755 wip-hugo/routines/memory/pixel_draw.s create mode 100755 wip-hugo/run.sh create mode 100755 wip-hugo/source.s diff --git a/wip-hugo/README.md b/wip-hugo/README.md new file mode 100755 index 0000000..c8d26a4 --- /dev/null +++ b/wip-hugo/README.md @@ -0,0 +1,50 @@ +# comodore64 + +# JUST F*** RUN ¯\\\_(ツ)_/¯ +in terminal run +``` +\. run.sh +``` +## Debug +Vice --> Activate Monitor + +## Chitty endian +2 bits 00 88 --> real world 8800 + +# Resourses + +## Compiler +[cc65](https://cc65.github.io/doc/ca65.html#ss4.1) + +## Comodore 64 Wiki +[wiki](https://www.c64-wiki.com/wiki/Memory_Map) + +## ASEMBLY 6502 instruction set +[good (expansive)](https://www.masswerk.at/6502/6502_instruction_set.html#CLD) +[wikipedia (minimalistic)](https://en.wikibooks.org/wiki/6502_Assembly) + + + +### sprites +[sprite](https://www.c64-wiki.com/wiki/Sprite#Sprite_priority) + +[sprite multiplex ](https://www.c64-wiki.com/wiki/Raster_interruptg) + +[sprite multiplex x2](http://selmiak.bplaced.net/games/c64/index.php?lang=eng&game=Tutorials&page=Sprite-Multiplexing) + +## Documentation of the vic chip +[text](https://www.zimmers.net/cbmpics/cbm/c64/vic-ii.txt) +[vic](https://csdb.dk/release/?id=154952) + +### Holding hand instructions :) +[codeburst hard asembly code](https://codeburst.io/lets-write-some-harder-assembly-language-code-c7860dcceba) + +[flag intro](http://www.6502.org/tutorials/vflag.html) + + + +## Basic +[peek and poke](https://en.wikipedia.org/wiki/PEEK_and_POKE) + +# Cool unexplored tools +[text](https://style64.org/cbmdisk/documentation/) \ No newline at end of file diff --git a/wip-hugo/STARTUP.s b/wip-hugo/STARTUP.s new file mode 100755 index 0000000..f4d5112 --- /dev/null +++ b/wip-hugo/STARTUP.s @@ -0,0 +1,99 @@ + + +;Settings positions + +CR1 = $d011; ;Grafic settings +VIC_bank_settings = $DD00 ; Vic position +Screen_RAM_settings =$D018 ;Screan 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 + +;Free upp memory +;https://www.c64-wiki.com/wiki/Bank_Switching +; +; + + +;Sets grafic mode [Standard bitmap mode] +;https://www.c64-wiki.com/wiki/Standard_Bitmap_Mode +LDA #%10111111 ; ECM = False +AND CR1 +STA CR1 + +LDA #%00100000; BMM = True +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 + +LDA #>VIC_bank +STA $FC +LDA #$5f3f +STA $FE +LDA #<$5f3f +STA $FD + +LDA #$0 +jsr memory_rec + +;Sets the screen color to black and white +LDA #>Screen_RAM +STA $FC +LDA #Screen_RAM_end +STA $FE +LDA # X + ; + + ; + + ;\/ + ; Y + ; + ; Let be this position in memory be stored in [$49, $4A] temporaraly + + + ; pos = x_offset + + LDA #%11111000 + AND $FC + STA $49 + + LDA $FD + STA $4A + + ; y_offset because chuncks aka y_offset_bc + LDA #%00000111 ; A = y (mod 8) + AND $FB + + ; pos += y_offset_bc + CLC + ADC $49 + STA $49 + LDA #$00 + ADC $4A + STA $4A + + + LDY $FB + LDA #$00 + STA $4B + ; y =8 translates to 320 bytes. + LDA #%11111000 ; A = y - [y (mod 8)] + AND $FB + STA $FB + + ;We need to A = A*40 =A * 2^3 * 5 + + ; A = A*2^3 + mult_16 $FB, $4B + mult_16 $FB, $4B + mult_16 $FB, $4B + + ; *5 + Add_16 $49, $4A, $FB, $4B + Add_16 $49, $4A, $FB, $4B + Add_16 $49, $4A, $FB, $4B + Add_16 $49, $4A, $FB, $4B + Add_16 $49, $4A, $FB, $4B + + STY $FB + + ;; add offset for where bitmap is + Add_16 $49, $4A, #Bitmap + + + ;;Let draw some stuff + LDX #$00 + LDA $FE + ORA ($49, X) + STA ($49, X) + + RTS + .endproc \ No newline at end of file diff --git a/wip-hugo/run.sh b/wip-hugo/run.sh new file mode 100755 index 0000000..3f9534c --- /dev/null +++ b/wip-hugo/run.sh @@ -0,0 +1,4 @@ +# !/bin/bash +pkill -f pulseaudio +killall x64sc ; cl65 -o file.prg -u __EXEHDR__ -t c64 -C c64-asm.cfg source.s && nohup flatpak run net.sf.VICE -windowypos 0 -windowxpos 960 -windowwidth 945 -windowheight 720 file.prg /dev/null & +#https://vice-emu.sourceforge.io/vice_7.html diff --git a/wip-hugo/source.s b/wip-hugo/source.s new file mode 100755 index 0000000..fea7685 --- /dev/null +++ b/wip-hugo/source.s @@ -0,0 +1,13 @@ +.include "STARTUP.s" +.include "macros/16aritmatic.s" + + +.include "routines/memory/line_up.s" + +loop_: +jmp loop_ + +.include "routines/memory/memory_rec.s" +.include "routines/memory/pixel_draw.s" + +;.include "routines/memory/memory.s"