├── .gitignore ├── BASIC ├── BASIC_CIA_STOG │ ├── STOG.D64 │ ├── STOG.PRG │ └── intelligence_agency_chars.d64 ├── BASIC_Directory │ └── directory.bas ├── BASIC_Get_Address_From_File │ └── getaddressfromfile.txt ├── BASIC_JOYPORT_READ │ └── basic_joyportread.d64 └── BASIC_StrobeLight │ ├── ReadMe.md │ ├── strobelight.bas │ └── strobelight.d64 ├── Commodore64-BASE ├── .gitignore ├── Build.bat ├── KickAss_AutoGen.cfg ├── README.md ├── build_linux.sh ├── main.asm └── prg_files │ ├── main.sym │ ├── program.d64 │ └── program.prg ├── Commodore64_Programming.code-workspace ├── Experiments ├── KickAss_AutoGen.cfg ├── Uncrunch Effect │ ├── Build.bat │ ├── prg_files │ │ ├── uncrunch-data.prg │ │ └── uncrunch_effect.sym │ └── uncrunch_effect.asm ├── b.bat ├── fp.asm ├── hires.asm ├── input.asm ├── interrupts.asm ├── kick example pic │ ├── FloydSteinberg.asm │ ├── FloydSteinberg.prg │ └── camel.jpg ├── kick example psid │ ├── Nightshift.sid │ ├── SID_Player.asm │ └── SID_Player.prg ├── prg_files │ ├── fp.prg │ ├── fp.sym │ ├── hires.prg │ ├── hires.sym │ ├── input.prg │ ├── input.sym │ ├── interrupts.prg │ ├── interrupts.sym │ ├── print.prg │ ├── print.sym │ ├── print2.prg │ ├── print2.sym │ ├── score.prg │ ├── score.sym │ ├── spell.prg │ ├── spell.sym │ ├── time.prg │ └── time.sym ├── print.asm ├── print.prg ├── print2.asm ├── print2_vars.asm ├── print_big.asm ├── score.asm ├── screen-spell.asm ├── screen-spell.petmate ├── screen.asm ├── sound effects.asm ├── spell.asm └── time.asm ├── Part 01 - Setup KickAssembler and VSCode ├── C64ProgrammingSeries-ep1.jpg └── ReadMe.md ├── Part 02 - Hello World ├── CityXenC64Part2.asm ├── ReadMe.md ├── images │ ├── C64ProgrammingSeries-ep2.jpg │ └── screen1.jpg └── prg_files │ ├── CityXenC64Part2.prg │ └── CityXenC64Part2.sym ├── Part 03 - Sinus Sprites ├── CityXenC64Part3.asm ├── ReadMe.md ├── cityxen_sprites.spr.spd ├── images │ ├── C64ProgrammingSeries-ep3.jpg │ └── screen1.jpg ├── prg_files │ ├── CityXenC64Part3.prg │ └── CityXenC64Part3.sym ├── sinustable.asm └── sprites.asm ├── Part 04 - Custom Chars, Smooth Scrolling ├── CustomCharsAndSmoothScroll.asm ├── ReadMe.md ├── characters-charset.asm ├── characters.vchar64proj ├── images │ ├── C64ProgrammingSeries-ep4.jpg │ └── screen1.jpg └── prg_files │ ├── CustomCharsAndSmoothScroll.prg │ └── CustomCharsAndSmoothScroll.sym ├── Part 05 - Scroller Message ├── ReadMe.md ├── ScrollerMessage.asm ├── characters-charset.asm ├── characters.vchar64proj ├── images │ ├── C64ProgrammingSeries-ep5.jpg │ └── screen1.jpg └── prg_files │ ├── ScrollerMessage.prg │ └── ScrollerMessage.sym ├── Part 06 - Petmate Screens and Keyboard ├── PetmateScreen.asm ├── ReadMe.md ├── images │ ├── C64ProgrammingSeries-ep6.jpg │ ├── screen1.jpg │ ├── screen2.jpg │ ├── screen3.jpg │ └── screen4.jpg ├── prg_files │ ├── PetmateScreen.prg │ └── PetmateScreen.sym ├── screen1.asm ├── screen1.petmate ├── screen2.asm ├── screen2.petmate ├── screen3.asm └── screen3.petmate ├── Part 07 - Disk Status and Directory ├── ReadMe.md ├── disktool-program-screen.asm ├── disktool-program-screen.petmate ├── disktool.asm ├── images │ ├── C64ProgrammingSeries-ep7.jpg │ ├── screen1.jpg │ └── screen2.jpg └── prg_files │ ├── disktool.d64 │ ├── disktool.prg │ └── disktool.sym ├── Part 08 - Disk Load and Save ├── ReadMe.md ├── diskdata.asm ├── diskstuff.prg ├── disktool-program-screen.asm ├── disktool-program-screen.petmate ├── disktool.asm ├── images │ ├── C64ProgrammingSeries-ep8.jpg │ ├── ss1-2.jpg │ ├── ss1.jpg │ ├── ss2.jpg │ ├── ss3.jpg │ └── ss4.jpg ├── load_address.bas ├── prg_files │ ├── disktool.prg │ ├── disktool.sym │ └── testdisk.d64 └── testdisk.d64 ├── Part 09 - Disk Initialize and Erase File ├── ReadMe.md ├── diskdata.asm ├── disktool-program-screen.asm ├── disktool-program-screen.petmate ├── disktool.asm ├── erasefile.bas ├── images │ ├── C64ProgrammingSeries-ep9.jpg │ └── ss1.jpg └── prg_files │ ├── disktool.prg │ ├── disktool.sym │ └── testdisk.d64 ├── Part 10 - Simple IRQ Timers ├── ReadMe.md ├── images │ └── C64ProgrammingSeries-ep10.jpg ├── prg_files │ ├── simple_irq_timers.prg │ └── simple_irq_timers.sym └── simple_irq_timers.asm ├── Part 11 - Funky BASIC Lines ├── ReadMe.md ├── funkybasic.asm ├── images │ └── C64PS-ep11.jpg └── prg_files │ ├── funkybasic.prg │ └── funkybasic.sym ├── Part 12 - Long Text Scrollers - Zero Page ├── ReadMe.md ├── images │ └── C64ProgrammingSeries-ep12.jpg ├── long_text_scroller.asm └── prg_files │ ├── long_text_scroller.prg │ └── long_text_scroller.sym ├── Part 13 - Sound Effects Using Sound FX Kit ├── ReadMe.md ├── images │ └── C64ProgrammingSeries-ep13.jpg ├── prg_files │ ├── soundeffects.prg │ └── soundeffects.sym ├── sfxwdp.prg └── soundeffects.asm ├── Part 14 - RLE Compression ├── Part 14 - RLE Compression.code-workspace ├── PetmateScreenRLE.asm ├── original │ ├── PetmateScreenAcmeRLE.zip │ ├── PetmateScreenAcmeRLE_original.asm │ ├── rle_compress.prg │ └── rle_compress_original.asm ├── prg_files │ ├── PetmateScreen (From Part 6).prg │ ├── PetmateScreenRLE.prg │ ├── PetmateScreenRLE.sym │ ├── rle-compress.prg │ ├── rle-compress.sym │ ├── rle_compress.prg │ ├── rle_compress.sym │ ├── screen.prg │ └── screen.sym ├── rle-compress.asm ├── screendata.asm ├── screendata_rle.asm ├── screens.asm └── util │ ├── conv.php │ ├── screen-rle-hex.out │ └── screen-rle-hex.txt ├── Part 15 - RLE Crunch - DeCrunch ├── prg_files │ ├── rle-crunch.d64 │ ├── rle-crunch.prg │ ├── rle-crunch.sym │ ├── screens.prg │ └── screens.sym ├── rle-crunch.asm ├── rle-decrunch.asm ├── screendata.asm └── screens.asm ├── ReadMe.md ├── include ├── CityXenLib.asm ├── CityXenLibCode.asm ├── Constants.asm ├── DrawPetMateScreen.asm ├── Macros.asm ├── Music.asm ├── SpriteManagement.asm ├── disk.il.asm ├── honkheckbutt.il.asm ├── input.il.asm ├── music.il.asm ├── print.il.asm ├── print │ ├── print.asm │ ├── print_ascii_to_petscii.asm │ ├── print_hex.asm │ ├── print_leading_zeros_as_spaces.asm │ ├── print_no_leading_zeros.asm │ ├── print_screencode_to_petscii.asm │ ├── u_calculate_color_pos.asm │ └── u_calculate_screen_pos.asm ├── random.il.asm ├── rle.il.asm ├── score.il.asm ├── sfxkit.il.asm ├── string.il.asm ├── string │ ├── strcpy.asm │ ├── string_ascii_to_petscii.asm │ ├── string_buffer.asm │ ├── string_hex_to_val.asm │ ├── string_screencode_to_petscii.asm │ ├── strings.asm │ └── strlen.asm ├── sys.il.asm ├── timers.il.asm └── userport.il.asm ├── sfx ├── Sound_FX_Kit.d64 └── Sound_FX_Kit_Instructions (Page 35) Commodore_DiskUser_Issue_10_1989_May-Jun_text.pdf └── storage └── Compute's_Reference_Guide_to_Commodore_64_Graphics.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | Working 2 | -------------------------------------------------------------------------------- /BASIC/BASIC_CIA_STOG/STOG.D64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/BASIC/BASIC_CIA_STOG/STOG.D64 -------------------------------------------------------------------------------- /BASIC/BASIC_CIA_STOG/STOG.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/BASIC/BASIC_CIA_STOG/STOG.PRG -------------------------------------------------------------------------------- /BASIC/BASIC_CIA_STOG/intelligence_agency_chars.d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/BASIC/BASIC_CIA_STOG/intelligence_agency_chars.d64 -------------------------------------------------------------------------------- /BASIC/BASIC_Directory/directory.bas: -------------------------------------------------------------------------------- 1 | 2 | 10 dim fl$(256):fp=0 3 | 4970 open8,8,0,"$":fori=1to6:get#8,a$:next:ifa$=""thena$=chr$(0) 4 | 4990 a$=str$(asc(a$)):a$=right$(a$,len(a$)-1):printa$;" "; 5 | 4995 fori=1to26:get#8,a$:printa$;:next:print 6 | 5010 get#8,a$,b$:get#8,a$,b$:ifa$<>""thenc=asc(a$) 7 | 5030 ifb$<>""thenc=c+asc(b$)*256 8 | 5050 d$=str$(c):d$=right$(d$,len(d$)-1):printd$; 9 | 5055 fori=4tolen(d$)step-1:print" ";:next 10 | 5070 get#8,b$:ifst<>0then5250 11 | 5090 ifb$<>chr$(34)then5070 12 | 5095 f$="" 13 | 5110 nm=0:d$=" ":printchr$(34); 14 | 5130 get#8,b$:ifb$<>chr$(34)thenprintb$;:nm=nm+1:f$=f$+b$:goto5130 15 | 5150 printchr$(34);:fori=1to((15-nm)+len(d$)):print" ";:next 16 | 5170 get#8,b$:ifb$=" "then5170 17 | 5190 ch$=b$ 18 | 5210 get#8,a$:ch$=ch$+a$:ifa$<>""then5210 19 | 5230 printleft$(ch$,3) 20 | 5231 fl$(fp)=f$:fp=fp+1 21 | 5240 goto5010 22 | 5250 close8:print" blocks free":open15,8,15:input#15,a$:close15 23 | 5260 fori=0tofp-1 24 | 5265 open 1,8,0,fl$(i) 25 | 5266 get#1,x$,y$ 26 | 5267 print asc(x$+chr$(0))+256*asc(y$+chr$(0)); 27 | 5268 close1 28 | 5269 print "start address ";fl$(i) 29 | 5270 next 30 | 31 | 32 | -------------------------------------------------------------------------------- /BASIC/BASIC_Get_Address_From_File/getaddressfromfile.txt: -------------------------------------------------------------------------------- 1 | 10 f$="filename,p" 2 | 20 open1,8,0,f$:get#1,a$,b$:print asc(a$+chr$(0))+256*asc(b$+chr$(0)):close1 -------------------------------------------------------------------------------- /BASIC/BASIC_JOYPORT_READ/basic_joyportread.d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/BASIC/BASIC_JOYPORT_READ/basic_joyportread.d64 -------------------------------------------------------------------------------- /BASIC/BASIC_StrobeLight/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Strobe Light 2 | 3 | Strobe Light Program written in Commodore 64 BASIC 4 | 5 | (by Deadline) 6 | -------------------------------------------------------------------------------- /BASIC/BASIC_StrobeLight/strobelight.bas: -------------------------------------------------------------------------------- 1 | 0 rem strobe light by deadline 2 | 1 rem (not xamfear) 3 | 10 print "{cls}":rem (shift clr/home) 4 | 20 poke 53280,0 5 | 30 poke 53281,0 6 | 40 for i =0to60 7 | 50 next 8 | 60 poke 53280,1 9 | 70 poke 53281,1 10 | 80 goto 20 11 | 12 | -------------------------------------------------------------------------------- /BASIC/BASIC_StrobeLight/strobelight.d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/BASIC/BASIC_StrobeLight/strobelight.d64 -------------------------------------------------------------------------------- /Commodore64-BASE/.gitignore: -------------------------------------------------------------------------------- 1 | *.scratch 2 | -------------------------------------------------------------------------------- /Commodore64-BASE/Build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Build Script: Building %1 3 | start /b genkickass-script.bat -t C64 -o prg_files -m true -s true -l "RETRO_DEV_LIB" 4 | KickAss.bat main.asm 5 | -------------------------------------------------------------------------------- /Commodore64-BASE/KickAss_AutoGen.cfg: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | ## KickAss File Auto Generated by Retro Dev Tools by Deadline / CityXen # 3 | ## Download Retro Dev Tools from our github: https://github.com/cityxen # 4 | ## https://linktr.ee/cityxen # 5 | ######################################################################### 6 | -showmem 7 | -symbolfile 8 | -libdir "/home/deadline/git/gogs.sethcoder.com/retro-dev-tools/include/commodore" 9 | -odir "prg_files" 10 | -execute "/usr/bin/x64" 11 | -------------------------------------------------------------------------------- /Commodore64-BASE/README.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 BASE Project file 4 | 5 | Just an empty project with a couple of print lines to get you started 6 | 7 | ## Instructions: 8 | 9 | Install the Retro Dev Tools repository 10 | 11 | ``` 12 | 13 | git clone https://github.com/cityxen/retro-dev-tools 14 | 15 | ``` 16 | 17 | 18 | ### Windows 19 | 20 | Add Retro Dev Tools bin-win folder to your environment path. Example: https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/ 21 | 22 | Alternatively, you can type it on the command line 23 | 24 | ``` 25 | 26 | set PATH=%PATH%;X:\path\to\retro-dev-tools\bin-win\ 27 | 28 | ``` 29 | 30 | Restart Computer 31 | 32 | ### Linux 33 | 34 | Add Retro Dev Tools bin-linux folder to your environment path. 35 | 36 | ``` 37 | 38 | echo "export PATH=$PATH:/path/to/retro-dev-lib/bin-linux" >> ~/.bashrc 39 | 40 | ``` 41 | 42 | Restart Computer 43 | 44 | ## After Installation 45 | 46 | Now you have the power of the Retro Dev Tools at your disposal. 47 | 48 | All you have to do now is edit your asm file, then run the script. If you have everything installed properly, it should compile your program, place it into a disk file, and then run that disk file in the appropriate emulator. 49 | 50 | ### Windows 51 | 52 | ``` 53 | 54 | Build.bat 55 | 56 | ``` 57 | 58 | ### Linux 59 | 60 | ``` 61 | 62 | ./build_linux.sh 63 | 64 | ``` 65 | -------------------------------------------------------------------------------- /Commodore64-BASE/build_linux.sh: -------------------------------------------------------------------------------- 1 | dir=$(dirname 0) 2 | genkickass-script.py -t C64 -o prg_files -m true -s true -l "RETRO_DEV_LIB" 3 | kickass main.asm 4 | -------------------------------------------------------------------------------- /Commodore64-BASE/main.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////// 2 | // Commodore 64 BASE main file 3 | // 4 | // Machine: Commodore 64 5 | // Version: 1 6 | // Author: 7 | // 8 | // Assembly files are for use with KickAssembler 9 | // http://theweb.dk/KickAssembler 10 | // 11 | // Notes: If you're going to attempt to compile this, you'll 12 | // need the Macros and Constants from this repo: 13 | // https://github.com/cityxen/Commodore64_Programming 14 | // 15 | // How To setup KickAssembler in Windows 10: 16 | // https://www.youtube.com/watch?v=R9VE2U_p060 17 | // 18 | ////////////////////////////////////////////////////////////////////////// 19 | .var basic = $0801 20 | .var main = $080d 21 | .var music = 0 22 | irq1: 23 | 24 | .file [name="program.prg",segments="Main"] 25 | .disk [filename="program.d64", name="program", id="id" ] { 26 | [name="program", type="prg", segments="Main"] 27 | } 28 | 29 | .segment Main [] 30 | ////////////////////////////////////////////////////////// 31 | // START OF MAIN 32 | 33 | *=$0801 "BASIC" 34 | :BasicUpstart($0815) 35 | *=$080a "cITYxEN wORDS" 36 | .byte $3a,99,67,73,84,89,88,69,78,99 37 | *=$0815 "MAIN PROGRAM" 38 | 39 | //*=basic "basic" 40 | // BasicUpstart(main) 41 | //*=main "main" 42 | jmp start 43 | #import "RetroDevLib-C64.asm" 44 | start: 45 | 46 | ClearScreen(BLACK) 47 | PrintStrAtColor(0,0,"hello",WHITE) 48 | PrintStrAtRainbow(0,1,"hello rainbow") 49 | PrintDecAtColor(0,2,3,BLUE) 50 | 51 | loop: 52 | jmp loop 53 | rts 54 | 55 | // END OF MAIN 56 | /////////////////////////////////////////////////// 57 | 58 | words: 59 | .text "program" 60 | .byte 0 61 | 62 | 63 | -------------------------------------------------------------------------------- /Commodore64-BASE/prg_files/main.sym: -------------------------------------------------------------------------------- 1 | .label calculate_color_pos=$881 2 | .label var_joy_1_y=$8d5 3 | .label var_joy_1_x=$8d4 4 | .label increment_screen_pos=$86e 5 | .label print_hex=$810 6 | .label ddl_print_num_table=$8c4 7 | .label calculate_screen_pos=$844 8 | .label words=$99e 9 | .label var_joy_2_x=$8d8 10 | .label var_joy_2_y=$8d9 11 | .label print_hex_no_calc=$817 12 | .label var_joy_2_fire=$8da 13 | .label read_joystick_2_fire=$92e 14 | .label loop=$99a 15 | .label increment_color_pos=$8ab 16 | .label read_joystick_1_fire=$902 17 | .label start=$934 { 18 | } 19 | .label irq1=$2000 20 | .label addto_color_pos=$8b2 21 | .label read_joystick_2_b=$917 22 | .label read_joystick_2_a=$913 23 | .label read_joystick_2_d=$91f 24 | .label read_joystick_2_c=$91b 25 | .label rainbowtable=$8be 26 | .label addto_screen_pos=$875 27 | .label read_joystick_1_a=$8e7 28 | .label read_joystick_1_c=$8ef 29 | .label read_joystick_1_b=$8eb 30 | .label read_joystick_1_d=$8f3 31 | .label sub_read_joystick_2=$908 32 | .label sub_read_joystick_1=$8dc 33 | .label var_joy_1_fire_released=$8d7 34 | .label var_joy_1_fire=$8d6 35 | .label var_joy_2_fire_released=$8db 36 | .label print_hex_screencode_conversion_table=$834 37 | -------------------------------------------------------------------------------- /Commodore64-BASE/prg_files/program.d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Commodore64-BASE/prg_files/program.d64 -------------------------------------------------------------------------------- /Commodore64-BASE/prg_files/program.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Commodore64-BASE/prg_files/program.prg -------------------------------------------------------------------------------- /Commodore64_Programming.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | }, 6 | { 7 | "path": "../Games/Whackadoodle" 8 | } 9 | ], 10 | "settings": {} 11 | } -------------------------------------------------------------------------------- /Experiments/KickAss_AutoGen.cfg: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | ## KickAss File Auto Generated by Retro Dev Tools by Deadline / CityXen # 3 | ## Download Retro Dev Tools from our github: https://github.com/cityxen # 4 | ## https://linktr.ee/cityxen # 5 | ######################################################################### 6 | -showmem 7 | -symbolfile 8 | -libdir "E:\dev\github\cityxen\Commodore64_Programming\include" 9 | -odir "prg_files" 10 | -execute "E:\dev\github\cityxen\retro-dev-tools\emulators\vice\bin\x64sc.exe" 11 | -------------------------------------------------------------------------------- /Experiments/Uncrunch Effect/Build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Build Script: Building %1 3 | call genkickass-script.bat -t C64 -o prg_files -m true -s true -l "RETRO_DEV_LIB" 4 | call KickAss.bat Clicky.asm 5 | -------------------------------------------------------------------------------- /Experiments/Uncrunch Effect/prg_files/uncrunch-data.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/Uncrunch Effect/prg_files/uncrunch-data.prg -------------------------------------------------------------------------------- /Experiments/Uncrunch Effect/prg_files/uncrunch_effect.sym: -------------------------------------------------------------------------------- 1 | .label vars=$830 2 | .label mainloop=$847 3 | .label end_glitch=$863 4 | .label init=$830 5 | .label usend=$814 6 | -------------------------------------------------------------------------------- /Experiments/Uncrunch Effect/uncrunch_effect.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // Uncrunch Effect by Deadline 3 | ////////////////////////////////////////////////////////////////////////////////////// 4 | #import "../../Commodore64_Programming/include/Constants.asm" 5 | #import "../../Commodore64_Programming/include/DrawPetMateScreen.asm" 6 | 7 | // File stuff 8 | .file [name="uncrunch-data.prg", segments="Main"] 9 | 10 | 11 | ////////////////////////////////////////////////////////////////////////////////////// 12 | .segment Main [allowOverlap] 13 | * = $0801 "BASIC" 14 | .word usend // link address 15 | .word 2021 // line num 16 | .byte $9e // sys 17 | .text toIntString(init) 18 | .byte $3a,99,67,73,84,89,88,69,78,99 19 | usend: 20 | .byte 0 21 | .word 0 // empty link signals the end of the program 22 | * = $0830 "vars init" 23 | vars: 24 | 25 | init: 26 | 27 | lda #$93 28 | jsr KERNAL_CHROUT 29 | 30 | // Set initial sprites on or off 31 | lda #$00 32 | sta SPRITE_ENABLE 33 | 34 | 35 | // Set up sid to produce random values 36 | lda #$FF // maximum frequency value 37 | sta $D40E // voice 3 frequency low byte 38 | sta $D40F // voice 3 frequency high byte 39 | lda #$80 // noise waveform, gate bit off 40 | sta $D412 // voice 3 control register 41 | 42 | ////////////////////////////////////////////////// 43 | // MAINLOOP 44 | mainloop: 45 | 46 | // Check keyboard 47 | jsr KERNAL_GETIN 48 | clc 49 | 50 | !keycheck: 51 | cmp #$51 // Q 52 | bne !keycheck+ 53 | rts 54 | 55 | 56 | !keycheck: // end_keyboard_checks 57 | 58 | 59 | !animate: 60 | // do some glitchy looking stuff 61 | ldx #$00 62 | !again: 63 | 64 | lda $d41b 65 | cmp $c400 66 | beq !again- 67 | sta $c400 68 | 69 | sta $400,x 70 | inx 71 | bne !again- 72 | 73 | end_glitch: 74 | 75 | ldx #$00 76 | ldy #$00 77 | !: 78 | lda #$01 79 | sta $c000,y 80 | iny 81 | inx 82 | bne !- 83 | 84 | ldx #$00 85 | ldy #$00 86 | !: 87 | lda #$01 88 | sta $c000,y 89 | iny 90 | inx 91 | bne !- 92 | 93 | 94 | ldy #$00 95 | !: 96 | lda #$01 97 | sta $c000,y 98 | 99 | ldx #$00 100 | !: 101 | sta $c000,x 102 | inx 103 | cpx #$06 104 | bne !- 105 | 106 | iny 107 | sty $400+999 108 | sty COLOR_RAM+999 109 | bne !-- 110 | 111 | jmp mainloop 112 | 113 | // END MAINLOOP 114 | ////////////////////////////////////////////////// 115 | -------------------------------------------------------------------------------- /Experiments/b.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Build Script: Building %1 3 | call genkickass-script.bat -t C64 -o prg_files -m true -s true -l "E:\dev\github\cityxen\Commodore64_Programming\include" 4 | call KickAss.bat %1 -------------------------------------------------------------------------------- /Experiments/fp.asm: -------------------------------------------------------------------------------- 1 | #import "Constants.asm" 2 | #import "Macros.asm" 3 | #import "PrintMacros.asm" 4 | #import "print.il.asm" 5 | #import "sys.il.asm" 6 | 7 | CityXenUpstart(start) 8 | 9 | start: 10 | 11 | lda #LIGHT_BLUE 12 | sta print_hex_color 13 | lda #$93 14 | jsr $ffd2 15 | ldx #$00 16 | 17 | FPTest(numba1) 18 | FPTest(numba2) 19 | FPTest(numba3) 20 | FPTest(numba4) 21 | FPTest(numba5) 22 | 23 | rts 24 | 25 | ftw: 26 | PrintHexI_Range($61,8) 27 | rts 28 | 29 | .macro FPTest(num) { 30 | lda #num 33 | sta $7b 34 | clc 35 | lda num 36 | jsr FIN 37 | jsr FOUT 38 | 39 | PrintLF() 40 | zPrint(FSTR) 41 | PrintSPC() 42 | 43 | lda #num 46 | sta $7b 47 | clc 48 | lda num 49 | jsr FIN 50 | 51 | PrintHexI_Range($61,8) 52 | PrintLF() 53 | 54 | // Add it to itself 55 | lda #num 58 | sta $7b 59 | clc 60 | lda num 61 | jsr FIN 62 | jsr MOVFA 63 | lda $61 64 | jsr FADDT 65 | jsr FOUT 66 | zPrint(FSTR) 67 | PrintSPC() 68 | 69 | lda #<$0100 70 | sta $7a 71 | lda #>$0100 72 | sta $7b 73 | clc 74 | lda num 75 | jsr FIN 76 | PrintHexI_Range($61,8) 77 | PrintLF() 78 | 79 | 80 | 81 | } 82 | 83 | numba1: 84 | .text "1" 85 | .byte 0 86 | 87 | numba2: 88 | .text "2" 89 | .byte 0 90 | 91 | numba3: 92 | .text "3" 93 | .byte 0 94 | 95 | numba4: 96 | .text "4" 97 | .byte 0 98 | 99 | numba5: 100 | .text "5" 101 | .byte 0 102 | 103 | numba6: 104 | .text "6" 105 | .byte 0 106 | 107 | numba7: 108 | .text "7" 109 | .byte 0 110 | 111 | numba8: 112 | .text "8" 113 | .byte 0 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /Experiments/hires.asm: -------------------------------------------------------------------------------- 1 | /*╔════════════════════════════════════════════════════════════════════════════╗ 2 | ║╔══════════════════════╗ ┌──────┐ ║ 3 | ║║ BitMap Plotter ║ │AUTHOR├─┐ TWW / CREATORS ║ 4 | ║╚══════════════════════╝ └──────┘ └════════════════ ║ 5 | ║ ║ 6 | ║┌──────────────────────┐ ║ 7 | ║│▓▓▓▓ DESCRIPTION ▓▓▓▓▓│ ║ 8 | ║├──────────────────────┴───────────────────────────────────────────────────┐║ 9 | ║│Will create 4 tables to plott a pixel on a Hires Bitmap screen; │║ 10 | ║│- BitMask - $80, $40, $20, $10, $08, $04, $02, $01 │║ 11 | ║│- X_Table - $00 x 8, $08 x 8, $10 x 8, ... │║ 12 | ║│- Y_Table_Lo - GFX_MEM x 8, >GFX_MEM + $140 x 8, ... │║ 14 | ║│ │║ 15 | ║│GFX_MEM must be set to the correct Graphics Bank. │║ 16 | ║└──────────────────────────────────────────────────────────────────────────┘║ 17 | ║┌──────────────────────┐ ║ 18 | ║│▓▓▓▓▓ FOOTPRINT ▓▓▓▓▓▓│ ║ 19 | ║├──────────────────────┴─────────────┐ ║ 20 | ║│54 Bytes │ ║ 21 | ║└────────────────────────────────────┘ ║ 22 | ╚════════════════════════════════════════════════════════════════════════════╝*/ 23 | 24 | .const GFX_MEM = $2000 25 | 26 | .const BitMask = $0a00 27 | .const X_Table = $0b00 28 | .const Y_Table_Lo = $0c00 29 | .const Y_Table_Hi = $0d00 30 | 31 | ldx #$00 32 | lda #$80 33 | Loop1: 34 | sta BitMask,x 35 | ror 36 | bcc Skip1 37 | ror 38 | Skip1: 39 | tay 40 | txa 41 | and #%11111000 42 | sta X_Table,x 43 | tya 44 | inx 45 | bne Loop1 46 | 47 | lda #GFX_MEM 55 | sta Y_Table_Hi,x 56 | pla 57 | inx 58 | dey 59 | bpl Loop3 60 | inc SMC1+1 61 | clc 62 | adc #$40 63 | bcc Skip2 64 | inc SMC1+1 65 | Skip2: 66 | cpx #8*25 67 | bne Loop2 -------------------------------------------------------------------------------- /Experiments/input.asm: -------------------------------------------------------------------------------- 1 | #import "Constants.asm" 2 | #import "Macros.asm" 3 | #import "PrintMacros.asm" 4 | #import "input.il.asm" 5 | #import "print.il.asm" 6 | #import "sys.il.asm" 7 | 8 | CityXenUpstart(start) 9 | 10 | start: 11 | 12 | lda #LIGHT_BLUE 13 | sta print_hex_color 14 | lda #$93 15 | jsr $ffd2 16 | ldx #$00 17 | 18 | InputText2(user_name,15,10,10,1) 19 | 20 | lda #$93 21 | jsr $ffd2 22 | 23 | PrintSC2P(user_name) 24 | 25 | rts 26 | 27 | user_name: 28 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 29 | 30 | 31 | -------------------------------------------------------------------------------- /Experiments/interrupts.asm: -------------------------------------------------------------------------------- 1 | 2 | *=$0801 "BASIC UPSTART" 3 | BasicUpstart($080d) 4 | *=$080d "MAIN Program" 5 | 6 | 7 | init: 8 | sei // set interrupt bit, make the cpu ignore interrupt requests 9 | lda #%01111111 // switch off interrupt signals from cia-1 10 | sta $dc0d 11 | 12 | and $d011 // clear most significant bit of vic's raster register 13 | sta $d011 14 | 15 | lda $dc0d // acknowledge pending interrupts from cia-1 16 | lda $dd0d // acknowledge pending interrupts from cia-2 17 | 18 | lda #210 // set rasterline where interrupt shall occur 19 | sta $d012 20 | 21 | lda #irq 24 | sta $0315 25 | 26 | lda #%00000001 // enable raster interrupt signals from vic 27 | sta $d01a 28 | 29 | cli // clear interrupt flag, allowing the cpu to respond to interrupt requests 30 | rts 31 | 32 | irq: 33 | lda #$7 34 | sta $d020 // change border colour to yellow 35 | 36 | ldx #$9 // empty loop to do nothing for just under half a millisecond 37 | !pause: 38 | dex 39 | bne !pause- 40 | 41 | lda #$6 42 | sta $d020 // change border colour to yellow 43 | 44 | ldx #$9 // empty loop to do nothing for just under half a millisecond 45 | !pause: 46 | dex 47 | bne !pause- 48 | 49 | lda #$5 50 | sta $d020 // change border colour to yellow 51 | 52 | ldx #$9 // empty loop to do nothing for just under half a millisecond 53 | !pause: 54 | dex 55 | bne !pause- 56 | 57 | lda #$0 58 | sta $d020 // change border colour to black 59 | 60 | asl $d019 // acknowledge the interrupt by clearing the vic's interrupt flag 61 | 62 | jmp $ea31 // jump into kernal's standard interrupt service routine to handle keyboard scan, cursor display etc. -------------------------------------------------------------------------------- /Experiments/kick example pic/FloydSteinberg.asm: -------------------------------------------------------------------------------- 1 | BasicUpstart2(start) 2 | //-------------------------------------------------------------------------- 3 | //-------------------------------------------------------------------------- 4 | // Graphic conversion with FloydSteinberg 5 | //-------------------------------------------------------------------------- 6 | //-------------------------------------------------------------------------- 7 | 8 | start: sei 9 | lda #$3b 10 | sta $d011 11 | lda #$18 12 | sta $d018 13 | lda #BLACK 14 | sta $d020 15 | ldx #0 16 | lda #BLACK | (WHITE<<4) 17 | loop: sta $0400,x 18 | sta $0500,x 19 | sta $0600,x 20 | sta $0700,x 21 | inx 22 | bne loop 23 | jmp * 24 | 25 | *=$2000 "Picture" 26 | .var pic1 = floydSteinberg("camel.jpg") 27 | .fill 40*200, pic1.get(i) 28 | 29 | 30 | //-------------------------------------------------------------------------- 31 | 32 | .function floydSteinberg(filename) { 33 | .var width = 320 34 | .var height = 200 35 | 36 | .var picture = LoadPicture(filename) 37 | 38 | // Create intensity map 39 | .var intensityMap = List(); 40 | .var maxInt = $0; 41 | .var minInt = $ffffff 42 | .for (var y=0; y>8)&$ff,2) + pow((rgb>>16)&$ff,2)) 46 | .eval intensityMap.add(intensity) 47 | .eval maxInt = max(maxInt, intensity) 48 | .eval minInt = min(minInt, intensity) 49 | } 50 | .eval intensityMap.add(0) // Add extra colunn to catch overflow 51 | } 52 | .for (var x=0; xirq1 20 | sta $0315 21 | lda #$1b 22 | sta $d011 23 | lda #$80 24 | sta $d012 25 | lda #$7f 26 | sta $dc0d 27 | sta $dd0d 28 | lda #$81 29 | sta $d01a 30 | lda $dc0d 31 | lda $dd0d 32 | asl $d019 33 | cli 34 | jmp * 35 | 36 | //--------------------------------------------------------- 37 | irq1: asl $d019 38 | inc $d020 39 | jsr music.play // <- Here we get the play address from the sid file 40 | dec $d020 41 | jmp $ea81 42 | 43 | //--------------------------------------------------------- 44 | *=music.location "Music" 45 | .fill music.size, music.getData(i) // <- Here we put the music in memory 46 | 47 | //---------------------------------------------------------- 48 | // Print the music info while assembling 49 | .print "" 50 | .print "SID Data" 51 | .print "--------" 52 | .print "location=$"+toHexString(music.location) 53 | .print "init=$"+toHexString(music.init) 54 | .print "play=$"+toHexString(music.play) 55 | .print "songs="+music.songs 56 | .print "startSong="+music.startSong 57 | .print "size=$"+toHexString(music.size) 58 | .print "name="+music.name 59 | .print "author="+music.author 60 | .print "copyright="+music.copyright 61 | 62 | .print "" 63 | .print "Additional tech data" 64 | .print "--------------------" 65 | .print "header="+music.header 66 | .print "header version="+music.version 67 | .print "flags="+toBinaryString(music.flags) 68 | .print "speed="+toBinaryString(music.speed) 69 | .print "startpage="+music.startpage 70 | .print "pagelength="+music.pagelength 71 | -------------------------------------------------------------------------------- /Experiments/kick example psid/SID_Player.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/kick example psid/SID_Player.prg -------------------------------------------------------------------------------- /Experiments/prg_files/fp.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/prg_files/fp.prg -------------------------------------------------------------------------------- /Experiments/prg_files/fp.sym: -------------------------------------------------------------------------------- 1 | .label calculate_color_pos=$20d7 2 | .label a_reg=$2233 3 | .label increment_screen_pos=$20c4 4 | .label print_hex=$2045 5 | .label f=$2241 6 | .label calculate_screen_pos=$2085 7 | .label strbuf=$2114 8 | .label print_hex_no_calc=$204c 9 | .label x_reg=$2234 10 | .label increment_color_pos=$2101 11 | .label ascii_to_petscii=$2000 12 | .label numba5=$1191 13 | .label numba6=$1193 14 | .label numba7=$1195 15 | .label numba8=$1197 16 | .label numba1=$1189 17 | .label numba2=$118b 18 | .label numba3=$118d 19 | .label numba4=$118f 20 | .label start=$830 21 | .label zprint=$2215 22 | .label y_reg=$2235 23 | .label addto_color_pos=$2108 24 | .label print_hex_color=$2044 25 | .label addto_screen_pos=$20cb 26 | .label zero_strbuf=$2224 27 | .label screencode_to_kernel=$2016 28 | .label print_hex_inline=$2019 29 | .label ftw=$1120 { 30 | } 31 | .label tmp_1=$2236 32 | .label p_str_cpy=$2232 33 | .label tmp_3=$2238 34 | .label tmp_2=$2237 35 | .label print_hex_inline_conversion_table=$2034 36 | .label buf_crsr=$2214 37 | .label ascii_to_petscii_kp=$200b 38 | .label wait_vbl=$2239 39 | .label print_hex_screencode_conversion_table=$2075 40 | -------------------------------------------------------------------------------- /Experiments/prg_files/hires.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/prg_files/hires.prg -------------------------------------------------------------------------------- /Experiments/prg_files/hires.sym: -------------------------------------------------------------------------------- 1 | .label Skip2=$2033 2 | .label Skip1=$200b 3 | .label Loop3=$201a 4 | .label Loop2=$2018 5 | .label Loop1=$2004 6 | .label SMC1=$201e 7 | -------------------------------------------------------------------------------- /Experiments/prg_files/input.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/prg_files/input.prg -------------------------------------------------------------------------------- /Experiments/prg_files/input.sym: -------------------------------------------------------------------------------- 1 | .label il_it2_kb_chk_del_first_pos=$2170 2 | .label il_it2_txt_len=$20c8 3 | .label il_it2_trim=$21a9 4 | .label calculate_color_pos=$22c2 5 | .label screencode_to_petscii=$21d2 6 | .label increment_screen_pos=$22af 7 | .label wlz=$233d 8 | .label il_it2_txt_color_hi=$20c7 9 | .label il_it2_kb_num=$2181 10 | .label j1_left=$200c 11 | .label calculate_screen_pos=$2270 12 | .label j1_down=$200b 13 | .label wlyz=$2344 14 | .label sc2p_sub64=$21f2 15 | .label increment_color_pos=$22ec 16 | .label j1_button=$200e 17 | .label nzp1=$2319 18 | .label sc2p_add0=$21fc 19 | .label j2_up=$2027 20 | .label j2_right=$202a 21 | .label zprint=$22ff 22 | .label il_get_any_input=$2045 23 | .label y_reg=$2350 24 | .label nzprint=$2313 25 | .label il_it2_txt_loc=$20c3 26 | .label sc2p_add128=$21f6 27 | .label j1_up=$200a 28 | .label il_it2_reverse=$210b 29 | .label il_it2_kb_chk=$2122 30 | .label il_it2_cursor=$20ea 31 | .label tmp_1=$2351 32 | .label k_value=$2000 33 | .label tmp_3=$2353 34 | .label tmp_2=$2352 35 | .label sc2p_add64=$21f9 36 | .label il_it2_kb_chk_no_crs=$213d 37 | .label il_it2_kb_not_too_long=$214c 38 | .label print_hex_inline_conversion_table=$221f 39 | .label ascii_to_petscii_kp=$21c7 40 | .label il_get_key=$2001 41 | .label input_text2=$20eb 42 | .label il_it2_txt_color_lo=$20c6 43 | .label print_hex_screencode_conversion_table=$2260 44 | .label il_it2_txt_scr=$20c1 45 | .label il_get_j1_m2=$200f 46 | .label a_reg=$234e 47 | .label il_it2_buffer=$20c9 48 | .label get_any_input=$2045 49 | .label user_name=$880 50 | .label i_compare=$2044 51 | .label print_hex=$2230 52 | .label get_j2_m2=$202c 53 | .label get_key=$2001 54 | .label print_hex_no_calc=$2237 55 | .label il_it2_out=$21bb 56 | .label il_it2_kb_chk_not_del=$217b 57 | .label x_reg=$234f 58 | .label zpnzp_c=$234d 59 | .label ascii_to_petscii=$21bc 60 | .label il_it2_kb_chk_end=$2190 61 | .label get_j1_m2=$200f 62 | .label j2_left=$2029 63 | .label il_get_j2_m2=$202c 64 | .label start=$830 65 | .label il_it2_txt_loc_lo=$20c3 66 | .label j1_right=$200d 67 | .label addto_color_pos=$22f3 68 | .label il_it2_txt_scr_hi=$20c2 69 | .label il_it2_kb_chk_crs_not_revd=$2139 70 | .label print_hex_color=$222f 71 | .label addto_screen_pos=$22b6 72 | .label il_it2_txt_color=$20c6 73 | .label print_hex_inline=$21fd 74 | .label j2_down=$2028 75 | .label il_it2_txt_loc_hi=$20c4 76 | .label il_it2_txt_scr_lo=$20c1 77 | .label il_it2_txt_color_val=$20c5 78 | .label sc2p_sub128=$21ef 79 | .label wait_vbl=$2354 80 | .label il_it2_rereverse=$2197 81 | .label j2_button=$202b 82 | .label il_it2_buffer_end=$20e9 83 | -------------------------------------------------------------------------------- /Experiments/prg_files/interrupts.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/prg_files/interrupts.prg -------------------------------------------------------------------------------- /Experiments/prg_files/interrupts.sym: -------------------------------------------------------------------------------- 1 | .label init=$80d 2 | .label irq=$835 3 | -------------------------------------------------------------------------------- /Experiments/prg_files/print.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/prg_files/print.prg -------------------------------------------------------------------------------- /Experiments/prg_files/print.sym: -------------------------------------------------------------------------------- 1 | .label strbuf=$857 2 | .label zprint=$957 3 | .label program=$815 4 | .label no_rs232=$833 5 | .label zero_strbuf=$972 6 | .label up9600_ident=$966 7 | .label buf_crsr=$957 8 | -------------------------------------------------------------------------------- /Experiments/prg_files/print2.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/prg_files/print2.prg -------------------------------------------------------------------------------- /Experiments/prg_files/print2.sym: -------------------------------------------------------------------------------- 1 | .label calculate_color_pos=$8cd 2 | .label increment_screen_pos=$8ba 3 | .label print_hex=$843 4 | .label calculate_screen_pos=$890 5 | .label print_hex_no_calc=$84a 6 | .label increment_color_pos=$8f7 7 | .label textit=$126e 8 | .label printvar1=$10dc 9 | .label start=$1200 { 10 | } 11 | .label printvar3=$1107 12 | .label printvar2=$10dd 13 | .label zprint=$830 14 | .label addto_color_pos=$8fe 15 | .label addto_screen_pos=$8c1 16 | .label print_hex_inline=$867 17 | .label screen=$90a 18 | .label print_hex_screencode_conversion_table=$880 19 | -------------------------------------------------------------------------------- /Experiments/prg_files/score.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/prg_files/score.prg -------------------------------------------------------------------------------- /Experiments/prg_files/score.sym: -------------------------------------------------------------------------------- 1 | .label score=$b34 2 | .label calculate_color_pos=$98f 3 | .label a_reg=$b20 4 | .label increment_screen_pos=$97c 5 | .label score_digits=$b44 6 | .label wlz=$b04 7 | .label print_hex=$8fd 8 | .label f=$b2e 9 | .label calculate_screen_pos=$93d 10 | .label score_from_str=$b6a 11 | .label strbuf=$9cc 12 | .label print_hex_no_calc=$904 13 | .label wlyz=$b0b 14 | .label x_reg=$b21 15 | .label zpnzp_c=$b10 16 | .label increment_color_pos=$9b9 17 | .label ascii_to_petscii=$8b1 18 | .label nzp1=$ae1 19 | .label start=$830 20 | .label zprint=$acd 21 | .label y_reg=$b22 22 | .label nzprint=$adc 23 | .label score_reset=$b8e 24 | .label addto_color_pos=$9c0 25 | .label score_math_o=$b45 26 | .label print_hex_color=$8fc 27 | .label addto_screen_pos=$983 28 | .label zero_strbuf=$b11 29 | .label screencode_to_kernel=$8c7 30 | .label print_hex_inline=$8ca 31 | .label tmp_1=$b23 32 | .label p_str_cpy=$b1f 33 | .label tmp_3=$b25 34 | .label score_add=$ba3 35 | .label tmp_2=$b24 36 | .label score_to_str=$b46 37 | .label print_hex_inline_conversion_table=$8ec 38 | .label buf_crsr=$acc 39 | .label ascii_to_petscii_kp=$8bc 40 | .label wait_vbl=$b26 41 | .label print_hex_screencode_conversion_table=$92d 42 | .label score_str=$b39 43 | .label score_sub=$bd3 44 | -------------------------------------------------------------------------------- /Experiments/prg_files/spell.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/prg_files/spell.prg -------------------------------------------------------------------------------- /Experiments/prg_files/spell.sym: -------------------------------------------------------------------------------- 1 | .label mainloop=$81d { 2 | } 3 | .label screen_001=$2000 4 | -------------------------------------------------------------------------------- /Experiments/prg_files/time.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/prg_files/time.prg -------------------------------------------------------------------------------- /Experiments/prg_files/time.sym: -------------------------------------------------------------------------------- 1 | .label main=$80d 2 | -------------------------------------------------------------------------------- /Experiments/print.asm: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////// 2 | // Print stuff experiments 3 | ////////////////////////////////////////////////////////////////////////////////////// 4 | // Initial defines and imports 5 | // From https://github.com/cityxen/Commodore64_Programming 6 | // git clone https://github.com/cityxen/Commodore64_Programming 7 | #import "../include/Constants.asm" 8 | 9 | ////////////////////////////////////////////////////////////////////////////////////// 10 | // File stuff 11 | .file [name="print.prg", segments="Main"] 12 | 13 | ////////////////////////////////////////////////////////////////////////////////////// 14 | // BASIC Upstart stuff 15 | .segment Main [allowOverlap] 16 | *=$0801 "BASIC" 17 | :BasicUpstart($0815) 18 | *=$080a "cITYxEN wORDS" 19 | .byte $3a,99,67,73,84,89,88,69,78,99 20 | *=$0815 "MAIN PROGRAM" 21 | 22 | ////////////////////////////////////////////////////////////////////////////////////// 23 | // Program start 24 | program: 25 | lda #$00 // INITIALIZE STUFF 26 | sta BACKGROUND_COLOR 27 | sta BORDER_COLOR 28 | lda #$93 29 | jsr KERNAL_CHROUT 30 | lda #23 31 | sta $d018 // put to lower case mode 32 | 33 | lda #> no_rs232 34 | sta zp_tmp_hi 35 | lda #< no_rs232 36 | sta zp_tmp_lo 37 | jsr zprint 38 | rts 39 | 40 | no_rs232: 41 | .encoding "petscii_mixed" 42 | .text "Can not find RS-232 userport device" 43 | .byte 0 44 | 45 | ////////////////////////////////////////////////////////////////////////////////////// 46 | // string buffer data 47 | strbuf: 48 | .fill 256,0 49 | buf_crsr: 50 | .byte 51 | 52 | zprint: 53 | // uses zero page pointer to string which you have to set up prior to calling 54 | // ie; 55 | // lda #> up9600_write_string 56 | // sta zp_tmp_hi 57 | // lda #< up9600_write_string 58 | // sta zp_tmp_lo 59 | // jsr up9600_write_2 60 | ldx #$00 61 | !wl: 62 | lda (zp_tmp,x) 63 | beq !wl+ 64 | jsr $ffd2 65 | inc zp_tmp_lo 66 | jmp !wl- 67 | !wl: 68 | rts 69 | 70 | ////////////////////////////////////////////////////////////////////////////////////// 71 | // UP9600 write data 72 | up9600_ident: 73 | .encoding "ascii" // "screencode_mixed" "petscii_mixed" "screencode_lower" "petscii_lower" 74 | .text "IDENTIFY:C64" 75 | 76 | ////////////////////////////////////////////////////////////////////////////////////// 77 | // zero string buffer 78 | zero_strbuf: 79 | lda #$00 80 | ldx #$00 81 | !lp: 82 | sta strbuf,x 83 | inx 84 | bne !lp- 85 | stx buf_crsr 86 | rts 87 | 88 | -------------------------------------------------------------------------------- /Experiments/print.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/print.prg -------------------------------------------------------------------------------- /Experiments/print2.asm: -------------------------------------------------------------------------------- 1 | #import "../include/CityXenLib.asm" 2 | 3 | .file [name="print2.prg", segments="Main"] 4 | CityXenUpstart() // super duper CityXen code thingy 5 | #import "../include/CityXenLibCode.asm" 6 | #import "screen.asm" 7 | #import "print2_vars.asm" 8 | 9 | *=$1200 "Code" 10 | 11 | start: 12 | 13 | DrawPetMateScreen(screen) 14 | zPrint(textit) 15 | 16 | PrintLF() 17 | PrintHOME() 18 | lda #$03 19 | PrintHexI() 20 | PrintLF() 21 | 22 | zPrint(printvar2) 23 | 24 | rts 25 | 26 | textit: 27 | .byte 13 28 | .text "TEST TEXT IT" 29 | 30 | .byte 0 31 | -------------------------------------------------------------------------------- /Experiments/print2_vars.asm: -------------------------------------------------------------------------------- 1 | 2 | printvar1: 3 | .byte 0 4 | 5 | printvar2: 6 | .text "HEY THIS IS A VAR FOR THE PRINT 2 PROGRAM" 7 | .byte 0 8 | 9 | printvar3: 10 | .text "OUTPUT OUT PUT OUTPUT ALERT!" 11 | .byte 0 12 | -------------------------------------------------------------------------------- /Experiments/print_big.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Experiments/print_big.asm -------------------------------------------------------------------------------- /Experiments/score.asm: -------------------------------------------------------------------------------- 1 | #import "Constants.asm" 2 | #import "Macros.asm" 3 | #import "PrintMacros.asm" 4 | 5 | CityXenUpstart(start) 6 | 7 | start: 8 | 9 | lda #$93 10 | jsr $ffd2 11 | 12 | jsr score_reset 13 | 14 | PrintLF() 15 | PrintNZ(score_str) 16 | 17 | lda #$50 // set score val to 1 18 | sta score_math_o 19 | 20 | PrintLF() 21 | lda score_math_o 22 | PrintHexI() 23 | 24 | jsr score_add // add 1 25 | jsr score_add // add 1 26 | jsr score_add // add 1 27 | jsr score_add // add 1 28 | jsr score_add // add 1 29 | jsr score_add // add 1 30 | 31 | 32 | PrintLF() 33 | PrintNZ(score_str) 34 | 35 | PrintLF() 36 | 37 | lda #$5 // // set score val to 11 38 | sta score_math_o 39 | 40 | lda score_math_o 41 | PrintHexI() 42 | 43 | jsr score_sub // subtract 11 44 | 45 | PrintLF() 46 | PrintNZ(score_str) 47 | 48 | jsr score_reset 49 | 50 | PrintLF() 51 | PrintNZ(score_str) 52 | 53 | rts 54 | 55 | #import "print.il.asm" 56 | #import "sys.il.asm" 57 | #import "score.il.asm" 58 | -------------------------------------------------------------------------------- /Experiments/spell.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // SPELL! 3 | // by Deadline 4 | 5 | #import "../include/Constants.asm" 6 | #import "../include/Macros.asm" 7 | #import "../include/DrawPetMateScreen.asm" 8 | 9 | *=$2000 "SCREENS" 10 | #import "screen-spell.asm" 11 | 12 | *=$0801 "BASIC" 13 | BasicUpstart($0810) 14 | *=$0810 15 | ClearScreen(BLACK) // from Macros.asm 16 | mainloop: 17 | DrawPetMateScreen(screen_001) 18 | jmp mainloop 19 | -------------------------------------------------------------------------------- /Experiments/time.asm: -------------------------------------------------------------------------------- 1 | 2 | #import "../include/Constants.asm" 3 | 4 | *=$0801 "BASIC UPSTART" 5 | BasicUpstart($080d) 6 | *=$080d "MAIN Program" 7 | 8 | main: 9 | jsr KERNAL_RDTIM 10 | sta $0400 11 | stx $0401 12 | sty $0402 13 | jmp main -------------------------------------------------------------------------------- /Part 01 - Setup KickAssembler and VSCode/C64ProgrammingSeries-ep1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 01 - Setup KickAssembler and VSCode/C64ProgrammingSeries-ep1.jpg -------------------------------------------------------------------------------- /Part 01 - Setup KickAssembler and VSCode/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 1: Setting up KickAssembler and VSCode on Windows10 8 | https://youtu.be/R9VE2U_p060 9 | 10 | ![p1](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2001%20-%20Setup%20KickAssembler%20and%20VSCode/C64ProgrammingSeries-ep1.jpg) -------------------------------------------------------------------------------- /Part 02 - Hello World/CityXenC64Part2.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // CityXen Commodore 64 Programming Series Part 2 3 | // Hello World (with color printing) 4 | // by Deadline 5 | 6 | *=$0801 7 | BasicUpstart($0810) 8 | *=$0810 9 | 10 | lda #$93 // Clear Screen 11 | jsr $ffd2 // KERNAL CHROUT 12 | 13 | lda #BLACK // color black 14 | sta $D020 // Border color 15 | sta $D021 // Background color 16 | 17 | ldx #$ff // load x with 255 18 | loop: 19 | inx // increment x register 20 | lda hello_world,x // load accumulator with hello_world, (offset by x) 21 | jsr $ffd2 // KERNAL CHROUT 22 | bne loop // branch if not equal to loop 23 | 24 | ldx #$00 // load x with 0 25 | loop2: 26 | lda color_table,x // load accumulator with color_table, (offset by x) 27 | sta $D800,x // store at screen color ram, (offset by x) 28 | inx // increment x register 29 | cpx #12 // bug fix from video comment (thanks Asaf Saar) 30 | bne loop2 // branch if not equal to loop2 31 | rts // return from subroutine (end of program) 32 | 33 | hello_world: // character table label for the words hello world 34 | .text "HELLO WORLD" 35 | .byte 0 36 | 37 | color_table: // color table label 38 | .byte YELLOW,BLUE,DARK_GRAY,GRAY,LIGHT_GRAY,WHITE,LIGHT_GRAY,GRAY,DARK_GRAY,BLUE,YELLOW,WHITE 39 | 40 | -------------------------------------------------------------------------------- /Part 02 - Hello World/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 2: Hello World 8 | https://youtu.be/017LMlEqUO4 9 | 10 | ![p2](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2002%20-%20Hello%20World/images/C64ProgrammingSeries-ep2.jpg) -------------------------------------------------------------------------------- /Part 02 - Hello World/images/C64ProgrammingSeries-ep2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 02 - Hello World/images/C64ProgrammingSeries-ep2.jpg -------------------------------------------------------------------------------- /Part 02 - Hello World/images/screen1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 02 - Hello World/images/screen1.jpg -------------------------------------------------------------------------------- /Part 02 - Hello World/prg_files/CityXenC64Part2.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 02 - Hello World/prg_files/CityXenC64Part2.prg -------------------------------------------------------------------------------- /Part 02 - Hello World/prg_files/CityXenC64Part2.sym: -------------------------------------------------------------------------------- 1 | .label hello_world=$836 2 | .label loop=$81f 3 | .label loop2=$82a 4 | .label color_table=$842 5 | -------------------------------------------------------------------------------- /Part 03 - Sinus Sprites/CityXenC64Part3.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // CityXen Commodore 64 Programming Series Part 3 3 | // Bouncy CityXen Sprites 4 | // by Deadline 5 | // Get spritepad here: https://www.subchristsoftware.com/spritepad.htm 6 | // Get sinusmaker here: https://csdb.dk/release/?id=124272 7 | 8 | #import "../include/Constants.asm" 9 | 10 | *=$0801 "BASIC" 11 | :BasicUpstart($0810) 12 | *=$0810 13 | 14 | .var sin_counter0 = $0a90 15 | .var sin_counter1 = $0a91 16 | .var sin_counter2 = $0a92 17 | .var sin_counter3 = $0a93 18 | .var sin_counter4 = $0a94 19 | .var sin_counter5 = $0a95 20 | .var sin_counter6 = $0a96 21 | .var sin_counter7 = $0a97 22 | .var color_flipper = $0a98 23 | 24 | .const X_POS = $6f 25 | .const Y_POS = $55 26 | 27 | begin_code: 28 | sei 29 | lda #BLACK 30 | sta BORDER_COLOR 31 | sta BACKGROUND_COLOR 32 | lda #$93 33 | jsr KERNAL_CHROUT 34 | 35 | lda #$7f 36 | sta SPRITE_ENABLE 37 | sta SPRITE_MULTICOLOR 38 | lda #LIGHT_GRAY 39 | sta SPRITE_MULTICOLOR_0 40 | lda #PURPLE 41 | sta SPRITE_MULTICOLOR_1 42 | lda #$00 43 | sta SPRITE_MSB_X 44 | 45 | lda #$2c; sta SPRITE_0_POINTER 46 | lda #$2d; sta SPRITE_1_POINTER 47 | lda #$2e; sta SPRITE_2_POINTER 48 | lda #$2f; sta SPRITE_3_POINTER 49 | lda #$30; sta SPRITE_4_POINTER 50 | lda #$31; sta SPRITE_5_POINTER 51 | lda #$32; sta SPRITE_6_POINTER 52 | 53 | lda #X_POS; sta SPRITE_0_X 54 | lda #X_POS+$11; sta SPRITE_1_X 55 | lda #X_POS+$22; sta SPRITE_2_X 56 | lda #X_POS+$36; sta SPRITE_3_X 57 | lda #X_POS+$4a; sta SPRITE_4_X 58 | lda #X_POS+$5e; sta SPRITE_5_X 59 | lda #X_POS+$72; sta SPRITE_6_X 60 | 61 | lda #Y_POS 62 | sta SPRITE_0_Y 63 | sta SPRITE_1_Y 64 | sta SPRITE_2_Y 65 | sta SPRITE_3_Y 66 | sta SPRITE_4_Y 67 | sta SPRITE_5_Y 68 | sta SPRITE_6_Y 69 | 70 | lda #DARK_GRAY 71 | sta SPRITE_0_COLOR 72 | sta SPRITE_1_COLOR 73 | sta SPRITE_2_COLOR 74 | sta SPRITE_3_COLOR 75 | sta SPRITE_4_COLOR 76 | sta SPRITE_5_COLOR 77 | sta SPRITE_6_COLOR 78 | 79 | lda #$00 80 | sta sin_counter0 81 | lda #$30 82 | sta sin_counter1 83 | lda #$50 84 | sta sin_counter2 85 | lda #$70 86 | sta sin_counter3 87 | lda #$90 88 | sta sin_counter4 89 | lda #$b0 90 | sta sin_counter5 91 | lda #$d0 92 | sta sin_counter6 93 | 94 | title_loop: 95 | 96 | lda #$10 97 | cmp VIC_RASTER_COUNTER 98 | bcc title_loop 99 | 100 | inc sin_counter0 101 | inc sin_counter1 102 | inc sin_counter2 103 | inc sin_counter3 104 | inc sin_counter4 105 | inc sin_counter5 106 | inc sin_counter6 107 | 108 | ldx sin_counter0 109 | lda sinetable,x 110 | adc #Y_POS 111 | sta SPRITE_0_Y 112 | 113 | ldx sin_counter1 114 | lda sinetable,x 115 | adc #Y_POS 116 | sta SPRITE_1_Y 117 | 118 | ldx sin_counter2 119 | lda sinetable,x 120 | adc #Y_POS 121 | sta SPRITE_2_Y 122 | 123 | ldx sin_counter3 124 | lda sinetable,x 125 | adc #Y_POS 126 | sta SPRITE_3_Y 127 | 128 | ldx sin_counter4 129 | lda sinetable,x 130 | adc #Y_POS 131 | sta SPRITE_4_Y 132 | 133 | ldx sin_counter5 134 | lda sinetable,x 135 | adc #Y_POS 136 | sta SPRITE_5_Y 137 | 138 | ldx sin_counter6 139 | lda sinetable,x 140 | adc #Y_POS 141 | sta SPRITE_6_Y 142 | 143 | lda #$DF 144 | cmp VIC_RASTER_COUNTER 145 | bcc title_loop 146 | 147 | ldx color_flipper 148 | inx 149 | cpx #$0c 150 | bne colorjump 151 | ldx #$00 152 | colorjump: 153 | stx color_flipper 154 | lda colortable,x 155 | sta SPRITE_MULTICOLOR_1 156 | jmp title_loop 157 | 158 | colortable: 159 | .byte PURPLE,DARK_GRAY,DARK_GRAY,GRAY,LIGHT_GRAY,WHITE,CYAN,WHITE,LIGHT_GRAY,GRAY,DARK_GRAY,DARK_GRAY,PURPLE 160 | 161 | #import "sinustable.asm" 162 | *=$0b00 "Sprites" 163 | #import "sprites.asm" 164 | 165 | -------------------------------------------------------------------------------- /Part 03 - Sinus Sprites/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 3: Sinus Sprites 8 | https://youtu.be/-UmPO8koghQ 9 | 10 | ![p3](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2003%20-%20Sinus%20Sprites/images/C64ProgrammingSeries-ep3.jpg) -------------------------------------------------------------------------------- /Part 03 - Sinus Sprites/cityxen_sprites.spr.spd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 03 - Sinus Sprites/cityxen_sprites.spr.spd -------------------------------------------------------------------------------- /Part 03 - Sinus Sprites/images/C64ProgrammingSeries-ep3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 03 - Sinus Sprites/images/C64ProgrammingSeries-ep3.jpg -------------------------------------------------------------------------------- /Part 03 - Sinus Sprites/images/screen1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 03 - Sinus Sprites/images/screen1.jpg -------------------------------------------------------------------------------- /Part 03 - Sinus Sprites/prg_files/CityXenC64Part3.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 03 - Sinus Sprites/prg_files/CityXenC64Part3.prg -------------------------------------------------------------------------------- /Part 03 - Sinus Sprites/prg_files/CityXenC64Part3.sym: -------------------------------------------------------------------------------- 1 | .label colorjump=$946 2 | .label title_loop=$8cc 3 | .label sinetable=$95f 4 | .label begin_code=$810 5 | .label colortable=$952 6 | .label cityxen_sprites=$b00 7 | -------------------------------------------------------------------------------- /Part 03 - Sinus Sprites/sinustable.asm: -------------------------------------------------------------------------------- 1 | sinetable: 2 | .byte $11,$11,$11,$12,$12,$12,$13,$13,$14,$14,$14,$15,$15,$16,$16,$16 3 | .byte $17,$17,$17,$18,$18,$18,$19,$19,$19,$1a,$1a,$1a,$1b,$1b,$1b,$1c 4 | .byte $1c,$1c,$1c,$1d,$1d,$1d,$1d,$1e,$1e,$1e,$1e,$1e,$1f,$1f,$1f,$1f 5 | .byte $1f,$1f,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20 6 | .byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$1f 7 | .byte $1f,$1f,$1f,$1f,$1f,$1e,$1e,$1e,$1e,$1e,$1d,$1d,$1d,$1d,$1c,$1c 8 | .byte $1c,$1b,$1b,$1b,$1b,$1a,$1a,$1a,$19,$19,$19,$18,$18,$18,$17,$17 9 | .byte $16,$16,$16,$15,$15,$15,$14,$14,$13,$13,$13,$12,$12,$11,$11,$11 10 | .byte $10,$10,$10,$0f,$0f,$0e,$0e,$0e,$0d,$0d,$0c,$0c,$0c,$0b,$0b,$0b 11 | .byte $0a,$0a,$09,$09,$09,$08,$08,$08,$07,$07,$07,$06,$06,$06,$06,$05 12 | .byte $05,$05,$04,$04,$04,$04,$03,$03,$03,$03,$03,$02,$02,$02,$02,$02 13 | .byte $02,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 14 | .byte $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$02,$02 15 | .byte $02,$02,$02,$02,$03,$03,$03,$03,$03,$04,$04,$04,$04,$05,$05,$05 16 | .byte $05,$06,$06,$06,$07,$07,$07,$08,$08,$08,$09,$09,$09,$0a,$0a,$0a 17 | .byte $0b,$0b,$0b,$0c,$0c,$0d,$0d,$0d,$0e,$0e,$0f,$0f,$0f,$10,$10,$10 -------------------------------------------------------------------------------- /Part 03 - Sinus Sprites/sprites.asm: -------------------------------------------------------------------------------- 1 | 2 | // SPRITE IMAGE DATA : 7 images : total size is 448 ($1c0) bytes. 3 | 4 | cityxen_sprites: 5 | 6 | .byte $00,$bf,$e0,$02,$ff,$f0,$03,$df,$f8,$0b,$7f,$fc,$0f,$ff,$fc,$0f 7 | .byte $fa,$f8,$2f,$e0,$a0,$2f,$c0,$00,$3f,$80,$00,$3f,$00,$00,$3f,$00 8 | .byte $00,$3f,$00,$00,$3f,$80,$a0,$3f,$c2,$f8,$2f,$e3,$fc,$2f,$ff,$fc 9 | .byte $0f,$ff,$f8,$0b,$ff,$f0,$03,$ff,$e0,$02,$ff,$c0,$00,$be,$00,$8b 10 | .byte $00,$0a,$00,$00,$0f,$80,$00,$2f,$c0,$00,$3d,$c0,$00,$37,$c0,$00 11 | .byte $bf,$c0,$00,$ff,$80,$00,$ff,$00,$02,$ff,$00,$03,$fe,$00,$03,$fc 12 | .byte $00,$0b,$fc,$00,$0f,$fc,$00,$0f,$fc,$00,$0f,$fc,$00,$0f,$f8,$00 13 | .byte $0b,$f0,$00,$03,$f0,$00,$02,$e0,$00,$00,$80,$00,$00,$00,$00,$8b 14 | .byte $02,$bf,$f8,$0b,$ff,$fc,$2f,$f7,$fc,$3f,$7f,$fc,$3d,$ff,$f8,$3f 15 | .byte $ff,$a0,$2f,$ff,$00,$0a,$be,$00,$00,$be,$00,$00,$fc,$00,$02,$fc 16 | .byte $00,$02,$f8,$00,$03,$f8,$00,$0b,$f0,$00,$0b,$f0,$00,$0f,$f0,$00 17 | .byte $0f,$f0,$00,$0f,$e0,$00,$0f,$e0,$00,$0b,$c0,$00,$00,$00,$00,$8b 18 | .byte $0a,$00,$a0,$0f,$00,$f0,$2f,$82,$f8,$3f,$c3,$dc,$3d,$c3,$fc,$3f 19 | .byte $c3,$fc,$2f,$e3,$fc,$0f,$f3,$f8,$0f,$f3,$f8,$0b,$fb,$f0,$03,$ff 20 | .byte $f0,$03,$ff,$e0,$02,$ff,$e0,$00,$ff,$c0,$00,$bf,$c0,$08,$bf,$80 21 | .byte $2e,$ff,$00,$3f,$fe,$00,$3f,$f8,$00,$2f,$e0,$00,$00,$00,$00,$8b 22 | .byte $00,$00,$20,$0a,$00,$b8,$2f,$00,$fc,$3f,$82,$dc,$3d,$c3,$fc,$3f 23 | .byte $e3,$f8,$2f,$fb,$f0,$0f,$ff,$e0,$0f,$ff,$c0,$0b,$ff,$00,$03,$ff 24 | .byte $80,$02,$ff,$e0,$0b,$ff,$f0,$0f,$ff,$f8,$2f,$fb,$fc,$3f,$e3,$fc 25 | .byte $3f,$c2,$fc,$3f,$80,$fc,$3f,$00,$b8,$2e,$00,$30,$00,$00,$00,$8b 26 | .byte $00,$00,$00,$00,$bf,$e0,$0b,$ff,$f0,$0d,$ff,$f0,$27,$ff,$e0,$3f 27 | .byte $80,$00,$3e,$00,$00,$3c,$2e,$00,$3e,$bf,$00,$2f,$fe,$00,$0f,$f8 28 | .byte $20,$0f,$e0,$f0,$2f,$c2,$f8,$3f,$83,$fc,$3f,$0b,$fc,$3f,$af,$f8 29 | .byte $2f,$ff,$f0,$0f,$ff,$e0,$0b,$ff,$80,$02,$fe,$00,$00,$00,$00,$8b 30 | .byte $00,$80,$28,$02,$c0,$b8,$0b,$f0,$fc,$0f,$72,$dc,$0f,$f3,$fc,$0f 31 | .byte $fb,$fc,$0f,$fa,$fc,$2f,$f8,$fc,$3f,$fe,$fc,$3f,$ff,$fc,$3f,$ff 32 | .byte $fc,$3f,$bf,$fc,$3f,$2f,$f8,$3f,$af,$f0,$3f,$ef,$f0,$3f,$cf,$f0 33 | .byte $3f,$0b,$e0,$3f,$0b,$c0,$2e,$03,$80,$0c,$02,$00,$00,$00,$00,$8b 34 | 35 | -------------------------------------------------------------------------------- /Part 04 - Custom Chars, Smooth Scrolling/CustomCharsAndSmoothScroll.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // CityXen Commodore 64 Programming Series Part 4 3 | // Custom Characters And Smooth Scroll & Introducing Kick Assembler Macros 4 | // by Deadline 5 | 6 | #import "../include/Constants.asm" // import constants.asm which contains helpful words instead of hex numbers 7 | #import "../include/Macros.asm" // import macros.asm which has macros to use 8 | 9 | *=$3000 "customfont" // specify that characters load in at $3000 10 | #import "characters-charset.asm" // import character data 11 | 12 | *=$0801 "BASIC" 13 | BasicUpstart($0810) 14 | *=$0810 15 | 16 | .const T_SCROLL_REG = $C000 17 | .const T_TIMER_1 = $C001 18 | .const T_TIMER_2 = $C002 19 | 20 | sei 21 | 22 | ClearScreen(BLACK) // from Macros.asm 23 | 24 | lda VIC_MEM_POINTERS // point to the new characters 25 | ora #$0c 26 | sta VIC_MEM_POINTERS 27 | 28 | lda VIC_CONTROL_REG_1 29 | and #$F7 30 | sta VIC_CONTROL_REG_1 31 | 32 | ldx #$18 33 | loop_crs_down: 34 | lda #$11 35 | jsr KERNAL_CHROUT 36 | dex 37 | cpx #$00 38 | bne loop_crs_down 39 | 40 | loop_char_scroll: 41 | lda VIC_CONTROL_REG_1 42 | and #$F8 43 | ora #$07 44 | sta VIC_CONTROL_REG_1 45 | 46 | lda #$0D // CR 47 | jsr KERNAL_CHROUT 48 | 49 | loop_print_hello_start: 50 | ldx #$FF 51 | loop_print_hello: 52 | inx 53 | lda hello_message,x 54 | jsr $ffd2 55 | bne loop_print_hello 56 | 57 | lda #$06 58 | sta T_SCROLL_REG 59 | 60 | loop_scroll_reg: 61 | 62 | clc 63 | lda VIC_RASTER_COUNTER 64 | cmp #$02 65 | bne loop_scroll_reg 66 | 67 | lda VIC_CONTROL_REG_1 68 | and #$F8 69 | ora T_SCROLL_REG 70 | sta VIC_CONTROL_REG_1 71 | 72 | lda #$00 73 | sta T_TIMER_1 74 | sta T_TIMER_2 75 | 76 | loop_timer_1: 77 | inc T_TIMER_1 78 | 79 | loop_timer_2: 80 | inc T_TIMER_2 81 | lda T_TIMER_2 82 | cmp #$FF 83 | bne loop_timer_2 84 | 85 | lda T_TIMER_1 86 | cmp #$05 87 | bne loop_timer_1 88 | 89 | 90 | dec T_SCROLL_REG 91 | lda T_SCROLL_REG 92 | cmp #$FF 93 | bne loop_scroll_reg 94 | 95 | jmp loop_char_scroll 96 | 97 | hello_message: 98 | .text " HELLO" 99 | .byte 0 100 | 101 | rts 102 | -------------------------------------------------------------------------------- /Part 04 - Custom Chars, Smooth Scrolling/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 4: Custom Characters, Smooth Scrolling & Macros 8 | https://youtu.be/eDrUNJQrAnU 9 | 10 | ![p4](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2004%20-%20Custom%20Chars%2C%20Smooth%20Scrolling/images/C64ProgrammingSeries-ep4.jpg) -------------------------------------------------------------------------------- /Part 04 - Custom Chars, Smooth Scrolling/characters.vchar64proj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 04 - Custom Chars, Smooth Scrolling/characters.vchar64proj -------------------------------------------------------------------------------- /Part 04 - Custom Chars, Smooth Scrolling/images/C64ProgrammingSeries-ep4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 04 - Custom Chars, Smooth Scrolling/images/C64ProgrammingSeries-ep4.jpg -------------------------------------------------------------------------------- /Part 04 - Custom Chars, Smooth Scrolling/images/screen1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 04 - Custom Chars, Smooth Scrolling/images/screen1.jpg -------------------------------------------------------------------------------- /Part 04 - Custom Chars, Smooth Scrolling/prg_files/CustomCharsAndSmoothScroll.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 04 - Custom Chars, Smooth Scrolling/prg_files/CustomCharsAndSmoothScroll.prg -------------------------------------------------------------------------------- /Part 04 - Custom Chars, Smooth Scrolling/prg_files/CustomCharsAndSmoothScroll.sym: -------------------------------------------------------------------------------- 1 | .label loop_char_scroll=$83a 2 | .label loop_print_hello=$84b 3 | .label loop_timer_1=$874 4 | .label loop_timer_2=$877 5 | .label charset=$3000 6 | .label loop_crs_down=$830 7 | .label hello_message=$895 8 | .label loop_scroll_reg=$859 9 | .label loop_print_hello_start=$849 10 | -------------------------------------------------------------------------------- /Part 05 - Scroller Message/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 5: Horizontal Scroller Message, Multicolor Characters & Raster line changes 8 | https://youtu.be/2EbZP9kp4zE 9 | 10 | ![p5](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2005%20-%20Scroller%20Message/images/C64ProgrammingSeries-ep5.jpg) -------------------------------------------------------------------------------- /Part 05 - Scroller Message/ScrollerMessage.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // CityXen Commodore 64 Programming Series Part 5 3 | // Horizontal Scroller Message with Color Cycle, Multicolor Characters, Raster line changes 4 | // by Deadline 5 | 6 | #import "../include/Constants.asm" 7 | #import "../include/Macros.asm" 8 | 9 | *=$3000 "customfont" 10 | #import "characters-charset.asm" 11 | 12 | .const SCREEN_BOTTOM_LEFT = $7C0 13 | .const SCREEN_BOTTOM_RIGHT = $7E7 14 | 15 | .const COLORS_BOTTOM_LEFT = $DBC0 16 | .const COLOR_VAR = $C000 17 | .const COLOR_TIMER = $C001 18 | 19 | *=$0801 "BASIC" 20 | BasicUpstart($0810) 21 | *=$0810 22 | 23 | ClearScreen(BLACK) // ClearScreen macro from Macros.asm 24 | 25 | lda #LIGHT_GRAY // Set up multicolor character colors 26 | sta BACKGROUND_COLOR_1 27 | lda #DARK_GRAY 28 | sta BACKGROUND_COLOR_2 29 | 30 | ldx #$00 31 | fillwhite: 32 | lda #WHITE 33 | sta COLOR_RAM,x 34 | lda #9 // 00001001 35 | sta COLOR_RAM+154,x 36 | inx 37 | cpx #$fe 38 | bne fillwhite 39 | 40 | ldx #$00 41 | txtloop: 42 | lda initial_text,x 43 | beq dotxtloop2 44 | sta SCREEN_RAM,x 45 | inx 46 | jmp txtloop 47 | 48 | dotxtloop2: 49 | ldx #64 50 | txtloop2: 51 | txa 52 | sta 1215,x 53 | inx 54 | cpx #76 55 | bne txtloop2 56 | 57 | ldx #96 58 | txtloop3: 59 | txa 60 | sta 1223,x 61 | inx 62 | cpx #108 63 | bne txtloop3 64 | 65 | jmp start 66 | 67 | initial_text: 68 | .text " cityxen scroller message by deadline" 69 | .byte 0 70 | 71 | start: 72 | 73 | ldx #39 // initial color fill of screen for the scroller message color 74 | lda #DARK_GRAY 75 | fillcolorloop: 76 | sta COLORS_BOTTOM_LEFT-1,x 77 | dex 78 | cpx #$ff 79 | bne fillcolorloop 80 | 81 | sei // disable interrupts 82 | 83 | lda VIC_MEM_POINTERS // point to the new characters 84 | ora #$0c 85 | sta VIC_MEM_POINTERS 86 | 87 | loop1: 88 | 89 | lda #$5f // Wait for raster line $5f 90 | cmp VIC_RASTER_COUNTER 91 | bne loop1b // if not at $5f, goto loop1b 92 | 93 | lda VIC_CONTROL_REG_2 // Turn on multicolor mode 94 | ora #16 95 | sta VIC_CONTROL_REG_2 96 | 97 | lda #WHITE // Change border to white 98 | sta BORDER_COLOR 99 | 100 | loop1b: 101 | lda #$f2 // Wait for raster line $f2 102 | cmp VIC_RASTER_COUNTER 103 | bne loop1 // if not at $f2, goto loop1 104 | 105 | lda VIC_CONTROL_REG_2 // Turn off multicolor character mode 106 | and #239 107 | sta VIC_CONTROL_REG_2 108 | 109 | lda #BLACK // change border to black 110 | sta BORDER_COLOR 111 | 112 | varlabel: 113 | lda #$00 // go into 38 column mode and set scroll bits 114 | and #$07 // varlabel+1 will be changed with self modifying code 115 | sta VIC_CONTROL_REG_2 116 | 117 | loop2: 118 | lda #$ff // wait for raster line $ff 119 | cmp VIC_RASTER_COUNTER 120 | bne loop2 121 | 122 | lda #$c8 // reset the borders to 40 column mode 123 | sta VIC_CONTROL_REG_2 124 | 125 | dec varlabel+1 126 | lda varlabel+1 127 | and #$07 128 | cmp #$07 129 | bne skipmove 130 | 131 | // Move scroller characters 132 | ldx #$00 133 | mvlp1: 134 | lda SCREEN_BOTTOM_LEFT+1,x 135 | sta SCREEN_BOTTOM_LEFT,x 136 | inx 137 | cpx #39 138 | bne mvlp1 139 | 140 | mvlp2: // put character from scroller message onto bottom right 141 | ldx #$00 142 | lda hello_message,x 143 | sta SCREEN_BOTTOM_RIGHT 144 | inx 145 | lda hello_message,x 146 | cmp #$ff 147 | bne mvover1 148 | ldx #$00 149 | mvover1: 150 | stx mvlp2+1 151 | 152 | skipmove: 153 | // color cycling 154 | 155 | inc COLOR_TIMER 156 | lda COLOR_TIMER 157 | cmp #$05 158 | beq more_color 159 | jmp loop1 160 | 161 | more_color: 162 | lda #$00 // reset color timer 163 | sta COLOR_TIMER 164 | 165 | // move colors 166 | ldx #39 167 | cycle_colors: 168 | lda COLORS_BOTTOM_LEFT-1,x 169 | sta COLORS_BOTTOM_LEFT,x 170 | dex 171 | cpx #$ff 172 | bne cycle_colors 173 | 174 | inc COLOR_VAR 175 | ldx COLOR_VAR 176 | lda color_table,x 177 | cmp #$ff 178 | beq reset_colors 179 | sta COLORS_BOTTOM_LEFT 180 | jmp loop1 181 | 182 | reset_colors: 183 | lda #$ff 184 | sta COLOR_VAR 185 | 186 | jmp loop1 187 | 188 | hello_message: 189 | .encoding "screencode_upper" 190 | .text " HELLO, THIS IS A HORIZONTAL SCROLLER MESSAGE BY DEADLINE OF CITYXEN. THIS IS " 191 | .text "A MODIFIED VERSION OF THE EXAMPLE PROVIDED WITH KICKASSEMBLER. IT IS " 192 | .text "PART 5 OF THE COMMODORE 64 PROGRAMMING SERIES VIDEOS ON OUR YOUTUBE CHANNEL..." 193 | .byte $ff 194 | 195 | color_table: 196 | .byte DARK_GRAY, GRAY, LIGHT_GRAY, WHITE, LIGHT_GRAY, GRAY, DARK_GRAY 197 | .byte $ff 198 | -------------------------------------------------------------------------------- /Part 05 - Scroller Message/characters.vchar64proj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 05 - Scroller Message/characters.vchar64proj -------------------------------------------------------------------------------- /Part 05 - Scroller Message/images/C64ProgrammingSeries-ep5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 05 - Scroller Message/images/C64ProgrammingSeries-ep5.jpg -------------------------------------------------------------------------------- /Part 05 - Scroller Message/images/screen1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 05 - Scroller Message/images/screen1.jpg -------------------------------------------------------------------------------- /Part 05 - Scroller Message/prg_files/ScrollerMessage.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 05 - Scroller Message/prg_files/ScrollerMessage.prg -------------------------------------------------------------------------------- /Part 05 - Scroller Message/prg_files/ScrollerMessage.sym: -------------------------------------------------------------------------------- 1 | .label loop2=$8ca 2 | .label more_color=$911 3 | .label loop1=$89b 4 | .label skipmove=$904 5 | .label fillwhite=$829 6 | .label mvover1=$901 7 | .label reset_colors=$936 8 | .label txtloop=$83a 9 | .label mvlp2=$8ef 10 | .label mvlp1=$8e4 11 | .label initial_text=$85f 12 | .label start=$886 13 | .label color_table=$a21 14 | .label charset=$3000 15 | .label dotxtloop2=$846 16 | .label loop1b=$8af 17 | .label hello_message=$93e 18 | .label cycle_colors=$918 19 | .label varlabel=$8c3 20 | .label txtloop2=$848 21 | .label txtloop3=$853 22 | .label fillcolorloop=$88a 23 | -------------------------------------------------------------------------------- /Part 06 - Petmate Screens and Keyboard/PetmateScreen.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // CityXen Commodore 64 Programming Series Part 6 3 | // Petmate screens and Reading Keyboard Input 4 | // by Deadline 5 | 6 | #import "../include/Constants.asm" 7 | #import "../include/Macros.asm" 8 | #import "../include/DrawPetMateScreen.asm" 9 | 10 | *=$09a3 "SCREENS" 11 | #import "screen1.asm" 12 | #import "screen2.asm" 13 | #import "screen3.asm" 14 | 15 | *=$0801 "BASIC" 16 | BasicUpstart($0810) 17 | *=$0810 18 | 19 | ClearScreen(BLACK) // from Macros.asm 20 | jsr write_instructions 21 | 22 | mainloop: 23 | jsr KERNAL_GETIN 24 | check_1_hit: 25 | cmp #$31 26 | bne check_2_hit 27 | DrawPetMateScreen(screen_001) 28 | jsr write_instructions 29 | jmp mainloop 30 | check_2_hit: 31 | cmp #$32 32 | bne check_3_hit 33 | DrawPetMateScreen(screen_002) 34 | jsr write_instructions 35 | jmp mainloop 36 | check_3_hit: 37 | cmp #$33 38 | bne check_4_hit 39 | DrawPetMateScreen(disk_menu) 40 | jsr write_instructions 41 | jmp mainloop 42 | check_4_hit: 43 | cmp #$34 44 | bne check_next_key 45 | DrawPetMateScreen(last_screen) 46 | jsr write_instructions 47 | jmp mainloop 48 | 49 | check_next_key: 50 | jmp mainloop 51 | 52 | write_instructions: 53 | ldx #$00 54 | w_i_loop: 55 | lda instructions,x 56 | beq w_i_exit 57 | sta 1988,x 58 | lda #WHITE 59 | sta $dbc4,x 60 | inx 61 | jmp w_i_loop 62 | w_i_exit: 63 | rts 64 | 65 | instructions: 66 | .text " press 1 to 4 to change screens " 67 | .byte 0 68 | 69 | -------------------------------------------------------------------------------- /Part 06 - Petmate Screens and Keyboard/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 6: Petmate Screens and Keyboard Reading 8 | https://youtu.be/XYHfms1-3Yo 9 | 10 | ![p6](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2006%20-%20Petmate%20Screens%20and%20Keyboard/images/C64ProgrammingSeries-ep6.jpg) 11 | ![screen1](https://raw.githubusercontent.com/cityxen/Commodore64_Programming/master/Part%2006%20-%20Petmate%20Screens%20and%20Keyboard/images/screen1.jpg) 12 | ![screen2](https://raw.githubusercontent.com/cityxen/Commodore64_Programming/master/Part%2006%20-%20Petmate%20Screens%20and%20Keyboard/images/screen2.jpg) 13 | ![screen2](https://raw.githubusercontent.com/cityxen/Commodore64_Programming/master/Part%2006%20-%20Petmate%20Screens%20and%20Keyboard/images/screen3.jpg) 14 | ![screen2](https://raw.githubusercontent.com/cityxen/Commodore64_Programming/master/Part%2006%20-%20Petmate%20Screens%20and%20Keyboard/images/screen4.jpg) 15 | 16 | -------------------------------------------------------------------------------- /Part 06 - Petmate Screens and Keyboard/images/C64ProgrammingSeries-ep6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 06 - Petmate Screens and Keyboard/images/C64ProgrammingSeries-ep6.jpg -------------------------------------------------------------------------------- /Part 06 - Petmate Screens and Keyboard/images/screen1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 06 - Petmate Screens and Keyboard/images/screen1.jpg -------------------------------------------------------------------------------- /Part 06 - Petmate Screens and Keyboard/images/screen2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 06 - Petmate Screens and Keyboard/images/screen2.jpg -------------------------------------------------------------------------------- /Part 06 - Petmate Screens and Keyboard/images/screen3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 06 - Petmate Screens and Keyboard/images/screen3.jpg -------------------------------------------------------------------------------- /Part 06 - Petmate Screens and Keyboard/images/screen4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 06 - Petmate Screens and Keyboard/images/screen4.jpg -------------------------------------------------------------------------------- /Part 06 - Petmate Screens and Keyboard/prg_files/PetmateScreen.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 06 - Petmate Screens and Keyboard/prg_files/PetmateScreen.prg -------------------------------------------------------------------------------- /Part 06 - Petmate Screens and Keyboard/prg_files/PetmateScreen.sym: -------------------------------------------------------------------------------- 1 | .label check_1_hit=$823 2 | .label w_i_loop=$970 3 | .label w_i_exit=$981 4 | .label mainloop=$820 5 | .label last_screen=$2119 6 | .label instructions=$982 7 | .label check_2_hit=$875 8 | .label check_next_key=$96b 9 | .label screen_002=$1175 10 | .label screen_001=$9a3 11 | .label check_3_hit=$8c7 12 | .label disk_menu=$1947 13 | .label check_4_hit=$919 14 | .label write_instructions=$96e 15 | -------------------------------------------------------------------------------- /Part 06 - Petmate Screens and Keyboard/screen2.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | // PETSCII memory layout (example for a 40x25 screen) 4 | // byte 0 = border color 5 | // byte 1 = background color 6 | // bytes 2-1001 = screencodes 7 | // bytes 1002-2001 = color 8 | screen_002: 9 | .byte 0,0 10 | .byte 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,97,254,220,252,225,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160 11 | .byte 160,160,160,160,160,160,160,160,160,160,160,160,160,160,105,226,226,251,160,97,249,220,249,225,160,236,226,226,251,160,160,160,160,160,160,160,160,160,160,160 12 | .byte 160,160,160,160,160,160,160,160,160,160,160,160,160,226,108,160,160,124,251,97,252,220,254,225,236,108,160,160,124,160,160,160,160,160,160,160,160,160,160,160 13 | .byte 160,160,160,160,160,160,160,160,160,160,160,160,105,254,160,160,220,160,123,126,251,220,236,124,108,160,160,220,252,225,160,160,160,160,160,160,160,160,160,160 14 | .byte 160,160,160,160,160,160,160,160,160,160,160,160,126,160,160,160,220,160,206,233,230,230,230,223,205,160,160,232,220,123,95,160,105,111,95,160,160,160,160,160 15 | .byte 160,160,160,160,160,160,160,160,160,160,160,97,254,160,160,232,160,206,160,160,160,102,160,160,160,205,160,160,220,160,252,32,78,78,233,160,160,160,160,160 16 | .byte 160,160,160,160,160,160,160,160,160,160,160,32,160,160,160,160,206,160,160,206,160,160,160,160,160,160,160,232,160,220,160,206,78,233,160,160,160,160,160,160 17 | .byte 160,160,160,160,160,160,160,160,160,160,105,254,160,160,220,207,247,247,247,208,160,160,160,102,102,160,160,160,160,232,206,206,124,160,160,160,160,160,160,160 18 | .byte 160,160,160,160,160,160,160,160,236,126,254,160,160,232,160,244,160,160,160,234,160,160,160,102,102,102,205,160,236,206,206,220,252,124,160,160,160,160,160,160 19 | .byte 160,160,160,160,160,160,160,160,126,160,160,160,160,160,160,244,160,160,160,234,160,160,160,160,160,102,102,244,214,214,160,160,220,252,124,160,160,160,160,160 20 | .byte 160,160,160,160,160,160,160,105,254,160,232,220,160,160,160,244,160,160,160,234,160,160,160,102,102,102,102,205,206,160,160,160,232,160,102,124,160,160,160,160 21 | .byte 160,160,160,160,160,160,126,254,160,160,160,220,160,160,160,244,160,160,160,234,160,160,160,102,160,160,102,102,160,160,160,160,160,220,160,102,95,160,160,160 22 | .byte 160,160,160,105,226,126,254,160,160,160,160,160,160,160,232,205,239,239,239,206,160,160,160,102,160,160,160,102,160,160,160,160,160,160,220,160,252,124,160,160 23 | .byte 160,160,105,254,160,160,160,220,160,160,160,255,160,160,160,127,230,230,127,160,160,160,160,160,160,127,160,251,160,160,160,251,160,160,232,220,160,252,124,226 24 | .byte 160,105,254,160,160,251,251,160,160,160,255,160,236,160,160,127,127,160,160,160,160,160,160,160,251,160,127,124,160,255,160,160,160,160,160,160,160,160,160,236 25 | .byte 160,160,223,127,32,98,123,251,127,160,160,160,32,123,124,32,223,251,160,160,160,160,102,102,102,102,108,233,98,124,160,252,225,225,251,160,160,160,236,233 26 | .byte 160,160,160,223,233,160,160,98,98,32,255,255,233,160,160,160,105,32,160,160,160,102,230,102,102,102,225,160,160,252,123,160,108,225,223,127,251,236,108,160 27 | .byte 160,160,160,160,160,160,160,160,160,124,32,223,160,160,160,160,126,160,160,102,102,230,230,102,102,108,254,160,160,160,252,124,225,233,225,223,98,98,160,160 28 | .byte 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,124,32,123,230,230,102,102,102,108,254,160,160,160,160,160,160,160,160,160,160,160,160,160,160 29 | .byte 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,97,102,102,102,102,102,225,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160 30 | .byte 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,252,123,230,102,102,230,225,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160 31 | .byte 160,160,15,13,9,14,15,21,19,160,160,160,160,160,160,160,160,160,160,97,102,230,230,92,254,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160 32 | .byte 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,97,230,230,92,98,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160 33 | .byte 160,160,160,160,6,15,18,5,19,8,1,4,15,23,9,14,7,160,160,252,123,230,92,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160 34 | .byte 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,97,92,98,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160 35 | .byte 7,2,8,7,2,7,2,7,2,8,2,7,8,8,2,7,7,8,8,2,11,12,15,2,8,7,7,8,7,8,7,2,8,2,7,8,2,2,7,2 36 | .byte 7,2,7,8,2,8,7,8,7,8,2,7,2,8,2,7,7,7,7,2,11,12,15,2,7,7,8,8,7,7,7,7,8,2,7,8,2,8,7,2 37 | .byte 7,2,7,8,2,2,7,8,7,7,7,2,2,2,1,1,1,7,7,7,11,12,15,2,7,1,1,1,2,2,7,7,2,7,2,8,2,8,2,2 38 | .byte 8,7,7,8,8,2,2,2,8,2,7,7,2,1,1,7,1,1,1,2,11,12,15,8,1,1,1,7,1,2,7,8,2,7,8,2,8,2,2,8 39 | .byte 8,2,7,2,8,8,7,7,2,2,8,2,2,1,7,15,7,1,1,1,11,12,15,1,1,7,7,7,1,1,2,8,2,1,2,8,7,7,2,8 40 | .byte 8,2,2,7,8,8,2,7,8,2,2,2,1,1,15,11,15,1,1,15,12,12,12,1,1,1,12,15,7,1,1,14,1,1,7,8,7,7,8,7 41 | .byte 2,8,2,2,7,7,7,7,7,8,2,14,1,15,15,12,1,1,15,15,15,12,15,15,15,1,15,15,12,1,1,1,1,7,7,2,7,2,7,8 42 | .byte 2,8,7,7,2,2,8,8,2,2,2,1,15,15,15,1,1,1,1,1,11,12,12,12,11,15,1,15,15,15,15,1,7,7,7,7,2,7,7,7 43 | .byte 7,7,7,8,7,2,2,8,2,2,1,1,15,15,12,1,1,2,1,1,11,12,12,15,12,11,15,1,1,12,12,1,1,7,7,8,2,2,2,2 44 | .byte 8,2,8,2,7,8,7,2,2,1,7,15,15,12,12,1,2,2,2,1,11,12,12,12,12,12,11,1,1,12,12,15,1,1,7,8,8,7,7,2 45 | .byte 7,8,8,8,7,8,2,2,1,1,15,15,15,12,11,1,1,2,1,1,11,15,12,15,15,12,11,11,1,15,12,12,15,1,1,7,7,7,2,2 46 | .byte 8,7,7,8,8,2,2,1,15,15,15,15,15,11,11,1,1,2,1,1,11,12,12,1,12,12,12,11,11,12,12,12,12,12,1,1,2,8,2,7 47 | .byte 8,8,7,2,8,2,1,15,15,15,15,12,12,12,11,1,1,1,1,1,11,12,12,1,12,11,12,12,12,15,12,12,12,12,12,1,1,8,8,8 48 | .byte 8,2,2,1,12,12,12,12,11,12,15,11,12,11,12,15,12,12,15,11,12,12,15,1,11,11,11,11,12,12,15,11,11,12,12,12,1,1,8,8 49 | .byte 8,8,1,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,15,12,12,1,11,11,11,11,11,11,12,11,11,11,11,12,12,1,1,1 50 | .byte 7,7,8,11,11,7,7,11,11,11,11,11,14,2,11,14,8,11,11,11,12,12,1,1,15,15,8,8,2,11,11,11,11,11,11,11,11,12,1,7 51 | .byte 7,8,8,8,2,7,7,7,8,11,11,11,2,2,8,8,8,14,15,15,12,11,1,15,15,15,8,8,7,2,2,11,2,11,2,11,11,11,7,7 52 | .byte 2,8,8,7,8,2,7,7,8,11,11,8,7,2,8,8,8,11,12,11,11,11,15,12,15,2,2,8,7,2,2,11,2,2,2,2,2,7,8,7 53 | .byte 7,8,2,7,7,8,7,2,8,8,7,2,8,2,7,8,11,8,8,11,11,11,12,15,2,2,8,7,8,7,2,8,2,7,7,8,2,7,8,8 54 | .byte 8,7,2,8,8,7,7,2,8,7,2,7,8,7,2,8,8,8,2,11,11,11,12,12,2,7,7,7,8,8,7,8,7,7,7,8,8,7,7,7 55 | .byte 2,2,7,2,8,8,8,8,7,2,7,2,8,7,8,8,2,7,2,2,11,11,12,11,2,2,8,7,2,7,7,2,8,8,8,8,2,7,7,7 56 | .byte 2,8,2,2,2,2,2,2,2,2,7,8,2,7,8,8,8,7,2,2,11,11,11,11,2,2,8,7,2,2,7,7,7,8,2,7,8,8,2,2 57 | .byte 8,8,7,7,7,8,8,2,2,7,8,7,2,7,2,2,8,2,2,2,11,11,11,2,2,8,8,2,7,7,7,7,2,8,8,7,7,2,8,8 58 | .byte 2,7,7,8,2,2,2,2,2,2,2,2,2,2,2,2,2,7,2,8,2,11,11,2,8,8,8,8,8,7,2,7,2,2,8,2,2,7,2,2 59 | .byte 2,8,8,8,7,2,2,8,8,2,2,2,2,2,7,7,8,8,8,2,2,11,2,2,8,2,2,7,8,8,2,7,2,2,7,8,2,7,7,2 60 | -------------------------------------------------------------------------------- /Part 07 - Disk Status and Directory/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 7: Disk Status and Directory 8 | https://youtu.be/t-hzeeFpD8c 9 | 10 | ![p7](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2007%20-%20Disk%20Status%20and%20Directory/images/C64ProgrammingSeries-ep7.jpg) 11 | 12 | ![p7-screen2](https://raw.githubusercontent.com/cityxen/Commodore64_Programming/master/Part%2007%20-%20Disk%20Status%20and%20Directory/images/screen2.jpg) 13 | -------------------------------------------------------------------------------- /Part 07 - Disk Status and Directory/disktool-program-screen.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | // PETSCII memory layout (example for a 40x25 screen)' 4 | // byte 0 = border color' 5 | // byte 1 = background color' 6 | // bytes 2-1001 = screencodes' 7 | // bytes 1002-2001 = color 8 | 9 | screen_disk_tool: 10 | .byte 0,0 11 | .byte 160,3,9,20,25,24,5,14,32,3,54,52,32,16,18,15,7,18,1,13,13,9,14,7,32,19,5,18,9,5,19,32,16,1,18,20,32,55,32,32 12 | .byte 160,32,4,9,19,11,32,19,20,1,20,21,19,44,32,4,9,18,5,3,20,15,18,25,32,1,14,4,32,4,18,9,22,5,32,35,32,32,32,32 13 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 14 | .byte 160,32,254,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,252,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 15 | .byte 160,32,160,160,206,247,160,160,160,160,228,131,137,148,153,152,133,142,228,228,228,228,228,228,160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 16 | .byte 160,32,160,160,244,160,233,160,160,160,228,228,132,137,147,139,148,143,143,140,228,228,228,228,160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 17 | .byte 160,32,160,160,244,160,95,160,160,160,228,228,228,133,152,129,141,144,140,133,228,228,228,228,160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 18 | .byte 160,32,160,160,205,239,160,160,160,160,228,228,228,228,144,146,143,135,146,129,141,228,228,228,160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 19 | .byte 160,32,251,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,236,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 20 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 21 | .byte 160,32,32,32,32,32,32,32,32,132,9,18,5,3,20,15,18,25,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 22 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 23 | .byte 160,32,32,32,32,32,32,32,32,137,14,9,20,9,1,12,9,26,5,32,4,9,19,11,32,40,16,1,18,20,32,57,41,32,32,32,32,32,32,32 24 | .byte 160,160,97,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 25 | .byte 160,226,126,32,32,32,32,32,32,147,1,22,5,32,6,9,12,5,32,32,40,16,1,18,20,32,56,41,32,32,32,32,32,32,32,32,32,32,32,32 26 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 27 | .byte 160,32,32,32,32,32,32,32,32,140,15,1,4,32,6,9,12,5,32,32,40,16,1,18,20,32,56,41,32,32,32,32,32,32,32,32,32,32,32,32 28 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 29 | .byte 160,32,32,32,32,32,32,32,32,133,18,1,19,5,32,6,9,12,5,32,40,16,1,18,20,32,57,41,32,32,32,32,32,32,32,32,32,32,32,32 30 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 31 | .byte 160,32,32,32,32,32,32,32,32,131,8,1,14,7,5,32,4,18,9,22,5,32,27,48,56,29,32,32,32,32,32,32,32,32,32,32,32,32,32,32 32 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,98,98,98,98,32,32,32,32,32,32,32,32,32,32,32 33 | .byte 160,32,32,32,32,32,32,32,32,19,148,1,20,21,19,32,32,32,32,32,32,32,32,108,255,160,160,160,160,127,123,32,32,32,32,32,32,32,32,32 34 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,255,160,254,160,160,252,160,127,32,32,32,32,32,32,32,32,32 35 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 36 | .byte 12,7,7,7,7,7,7,7,7,6,2,2,2,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,5,5,5,1,1,1,1,1,1,1,14,14 37 | .byte 12,14,7,7,7,7,7,7,7,7,7,7,7,1,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,1,1,1,1,1,1 38 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 39 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 40 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 41 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 42 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 43 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 44 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 45 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 46 | .byte 12,14,14,14,14,14,14,14,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 47 | .byte 12,0,11,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 48 | .byte 12,11,11,14,14,14,14,14,14,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,14,11,11,11,11,11,14,11,11,14,14,14,14,14,14,14 49 | .byte 12,12,12,14,14,14,14,14,14,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 50 | .byte 12,12,12,14,14,14,14,14,14,11,11,11,11,11,11,11,11,11,14,14,11,11,11,11,11,14,11,11,14,14,14,14,14,14,14,14,14,14,14,14 51 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 52 | .byte 12,14,14,14,14,14,14,14,14,11,11,11,11,11,11,11,11,11,1,14,11,11,11,11,11,14,11,11,14,14,14,14,14,14,14,14,14,14,14,14 53 | .byte 12,14,14,14,14,14,14,14,14,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 54 | .byte 12,14,14,14,14,14,14,14,14,11,11,11,11,11,11,11,11,11,11,14,11,11,11,11,11,14,11,11,14,14,14,14,14,14,14,14,14,14,14,14 55 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 56 | .byte 12,14,14,14,14,14,14,14,14,1,1,1,1,1,1,14,1,1,1,1,1,14,1,7,7,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14 57 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,12,12,12,12,14,14,14,14,14,14,14,14,14,14,14 58 | .byte 12,14,14,14,14,14,14,14,14,1,1,1,1,1,1,14,14,14,14,14,14,14,14,11,12,11,11,11,11,12,11,14,14,14,14,14,14,14,14,14 59 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,12,11,12,12,12,12,11,12,14,14,14,14,14,14,14,14,14 60 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 61 | -------------------------------------------------------------------------------- /Part 07 - Disk Status and Directory/disktool.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // CityXen Commodore 64 Programming Series Part 7 3 | // Disk Status and Directory 4 | // by Deadline 5 | // 6 | // Based on code converted to KickAssembler from: 7 | // https://codebase64.org/doku.php?id=base:reading_the_directory 8 | // 9 | 10 | #import "../include/Constants.asm" 11 | #import "../include/Macros.asm" 12 | #import "../include/DrawPetMateScreen.asm" 13 | 14 | *=$1000 15 | #import "disktool-program-screen.asm" 16 | 17 | .var drive_number = $fb 18 | 19 | *=$0801 "BASIC UPSTART" 20 | BasicUpstart($080d) 21 | *=$080d "MAIN Program" 22 | 23 | init: 24 | // Store 8 into drive number variable 25 | lda #$08 26 | sta drive_number 27 | 28 | // change to white print 29 | lda #$05 30 | jsr KERNAL_CHROUT 31 | 32 | start: 33 | // Draw Screen 34 | DrawPetMateScreen(screen_disk_tool) 35 | jsr draw_drive_number 36 | jmp mainloop 37 | 38 | draw_drive_number: 39 | // Show Drive Number on Screen 40 | lda drive_number 41 | clc // clear carry flag so we don't rotate carry into a 42 | rol // rotate left (multiply by 2) 43 | sec // sec carry flag for subtract operation 44 | sbc #$10 // subtract 16 45 | tax 46 | lda drive_number_text,x // get text indexed by x 47 | sta $0737 // put to screen 48 | lda drive_number_text+1,x 49 | sta $0738 50 | rts 51 | drive_number_text: 52 | .text "08091011" 53 | 54 | mainloop: 55 | jsr KERNAL_GETIN // Check keyboard for key hits 56 | 57 | // D (Directory) 58 | !check_key: 59 | cmp #KEY_D 60 | bne !check_key+ 61 | inc $d020 62 | jsr show_directory 63 | jmp start 64 | 65 | // C (Change Drive) 66 | !check_key: 67 | cmp #KEY_C 68 | bne !check_key+ 69 | inc drive_number 70 | lda drive_number 71 | cmp #$0c 72 | bne !cki+ 73 | lda #$08 74 | sta drive_number 75 | !cki: 76 | jsr draw_drive_number 77 | jmp mainloop 78 | 79 | // T (Status) 80 | !check_key: 81 | cmp #KEY_T 82 | bne !check_key+ 83 | lda #$13 // print home 84 | jsr KERNAL_CHROUT 85 | ldx #$16 // print down 22 times 86 | !cki: 87 | lda #$11 // down 88 | jsr KERNAL_CHROUT 89 | dex 90 | bne !cki- 91 | ldx #$10 // print right 16 times 92 | !cki: 93 | lda #$1d // right char 94 | jsr KERNAL_CHROUT 95 | dex 96 | bne !cki- 97 | jsr show_drive_status 98 | jmp mainloop 99 | 100 | !check_key: 101 | jmp mainloop 102 | 103 | show_directory: 104 | ClearScreen(BLACK) 105 | lda #dirname_end-dirname // set length of dirname 106 | ldx #dirname // hi byte of dirname 108 | jsr KERNAL_SETNAM 109 | lda #$02 // filenumber 110 | ldx drive_number // default to device number 8 111 | ldy #$00 // secondary address 112 | jsr KERNAL_SETLFS 113 | jsr KERNAL_OPEN 114 | bcs error 115 | ldx #$02 // set filenumber 116 | jsr KERNAL_CHKIN 117 | ldy #$04 // skip 4 bytes on first dir line 118 | bne skip2 119 | next: 120 | ldy #$02 // skip 2 bytes on all other lines 121 | skip2: 122 | jsr getbyte 123 | dey 124 | bne skip2 125 | jsr getbyte // get low byte of basic line number 126 | tay 127 | jsr getbyte // get high byte of basic line number 128 | pha 129 | tya 130 | tax 131 | pla 132 | jsr $bdcd // print basic line number 133 | lda #$20 // print space 134 | char: 135 | jsr KERNAL_CHROUT 136 | jsr getbyte 137 | bne char 138 | lda #$0d // carriage return character 139 | jsr KERNAL_CHROUT 140 | jsr KERNAL_STOP // run/stop pressed? 141 | bne next 142 | error: 143 | // check for error here 144 | exit: 145 | lda #$02 // filenumber 2 146 | jsr KERNAL_CLOSE 147 | jsr KERNAL_CLRCHN 148 | lda #$0d 149 | jsr KERNAL_CHROUT 150 | jsr show_drive_status 151 | ldx #$00 152 | anykey_text: 153 | lda dir_presskey_text,x 154 | beq !anykey+ 155 | jsr KERNAL_CHROUT 156 | inx 157 | jmp anykey_text 158 | !anykey: 159 | jsr KERNAL_WAIT_KEY 160 | beq !anykey- 161 | rts 162 | 163 | getbyte: 164 | jsr KERNAL_READST 165 | bne end 166 | jmp KERNAL_CHRIN 167 | end: 168 | pla 169 | pla 170 | jmp exit 171 | 172 | dirname: 173 | .text "$" 174 | dirname_end: 175 | dir_presskey_text: 176 | .encoding "screencode_mixed" 177 | .byte $0d 178 | .text "PRESS ANY KEY" 179 | .byte 0 180 | 181 | show_drive_status: 182 | lda #$00 183 | sta $90 // clear status flags 184 | lda drive_number // device number 185 | jsr KERNAL_LISTEN 186 | lda #$6f // secondary address 187 | jsr KERNAL_SECLSN 188 | jsr KERNAL_UNLSTN 189 | lda $90 190 | bne sds_devnp // device not present 191 | lda drive_number 192 | jsr KERNAL_TALK 193 | lda #$6f // secondary address 194 | jsr KERNAL_SECTLK 195 | sds_loop: 196 | lda $90 // get status flags 197 | bne sds_eof 198 | jsr KERNAL_IECIN 199 | jsr KERNAL_CHROUT 200 | jmp sds_loop 201 | sds_eof: 202 | jsr KERNAL_UNTALK 203 | rts 204 | sds_devnp: 205 | // handle device not present error handling 206 | rts 207 | -------------------------------------------------------------------------------- /Part 07 - Disk Status and Directory/images/C64ProgrammingSeries-ep7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 07 - Disk Status and Directory/images/C64ProgrammingSeries-ep7.jpg -------------------------------------------------------------------------------- /Part 07 - Disk Status and Directory/images/screen1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 07 - Disk Status and Directory/images/screen1.jpg -------------------------------------------------------------------------------- /Part 07 - Disk Status and Directory/images/screen2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 07 - Disk Status and Directory/images/screen2.jpg -------------------------------------------------------------------------------- /Part 07 - Disk Status and Directory/prg_files/disktool.d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 07 - Disk Status and Directory/prg_files/disktool.d64 -------------------------------------------------------------------------------- /Part 07 - Disk Status and Directory/prg_files/disktool.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 07 - Disk Status and Directory/prg_files/disktool.prg -------------------------------------------------------------------------------- /Part 07 - Disk Status and Directory/prg_files/disktool.sym: -------------------------------------------------------------------------------- 1 | .label draw_drive_number=$864 2 | .label drive_number_text=$879 3 | .label skip2=$8fc 4 | .label screen_disk_tool=$1000 5 | .label mainloop=$881 6 | .label dir_presskey_text=$956 7 | .label anykey_text=$936 8 | .label next=$8fa 9 | .label getbyte=$948 10 | .label end=$950 11 | .label start=$816 { 12 | } 13 | .label dirname=$955 14 | .label dirname_end=$956 15 | .label init=$80d 16 | .label show_drive_status=$965 17 | .label exit=$924 18 | .label sds_loop=$984 19 | .label char=$912 20 | .label sds_devnp=$995 21 | .label show_directory=$8cd { 22 | } 23 | .label error=$924 24 | .label sds_eof=$991 25 | -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 8: Disk Load and Save + SID Random Number Generation 8 | https://youtu.be/Zd19AuajTdQ 9 | 10 | ![p8](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2008%20-%20Disk%20Load%20and%20Save/images/C64ProgrammingSeries-ep8.jpg) 11 | 12 | ![p8-screen1](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2008%20-%20Disk%20Load%20and%20Save/images/ss1-2.jpg) 13 | 14 | ![p8-screen2](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2008%20-%20Disk%20Load%20and%20Save/images/ss2.jpg) 15 | 16 | ![p8-screen3](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2008%20-%20Disk%20Load%20and%20Save/images/ss3.jpg) 17 | 18 | ![p8-screen4](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2008%20-%20Disk%20Load%20and%20Save/images/ss4.jpg) 19 | 20 | 21 | -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/diskdata.asm: -------------------------------------------------------------------------------- 1 | diskdata: 2 | .byte $43,'c','i','t','y','x','e','n',$43,$43,'d','i','s','k','t','o','o','l',$43,$3e,0,0,0,0,0,0,0,0,0,0,0,0 3 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 4 | .byte 0,0,0,'d','a','t','a',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 5 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 6 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,$53,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 7 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 8 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 9 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 10 | 11 | copydiskdata: 12 | ldx #$00 13 | !cpdd: 14 | lda diskdata,x 15 | sta data_start,x 16 | inx 17 | bne !cpdd- 18 | rts 19 | 20 | displaydiskdata: 21 | ldx #$00 22 | !ddd: 23 | lda data_start,x 24 | sta $0400+400,x 25 | inx 26 | bne !ddd- 27 | rts 28 | 29 | viewdiskdata: 30 | ClearScreen(BLACK) 31 | jsr displaydiskdata 32 | ldx #$00 33 | !vdd: 34 | lda dir_presskey_text,x 35 | beq !vdd+ 36 | jsr KERNAL_CHROUT 37 | inx 38 | jmp !vdd- 39 | !vdd: 40 | jsr KERNAL_WAIT_KEY 41 | beq !vdd- 42 | rts 43 | 44 | randomizediskdata: 45 | ldx #$00 46 | !rdd: 47 | lda $d41b // (get random number from SID) 48 | cmp last_rand // check to remove duplicates 49 | beq !rdd- 50 | sta last_rand 51 | sta data_start,x 52 | inx 53 | bne !rdd- 54 | rts 55 | last_rand: 56 | .byte 0 -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/diskstuff.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 08 - Disk Load and Save/diskstuff.prg -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/disktool-program-screen.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | // PETSCII memory layout (example for a 40x25 screen)' 4 | // byte 0 = border color' 5 | // byte 1 = background color' 6 | // bytes 2-1001 = screencodes' 7 | // bytes 1002-2001 = color 8 | 9 | screen_disk_tool: 10 | .byte 0,0 11 | .byte 160,3,9,20,25,24,5,14,32,3,54,52,32,16,18,15,7,18,1,13,13,9,14,7,32,19,5,18,9,5,19,32,16,1,18,20,32,56,32,32 12 | .byte 160,32,4,9,19,11,32,12,15,1,4,32,1,14,4,32,19,1,22,5,32,4,1,20,1,32,43,32,19,9,4,32,18,1,14,4,15,13,32,32 13 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 14 | .byte 160,32,254,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,252,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 15 | .byte 160,32,160,160,206,247,160,160,160,160,228,131,137,148,153,152,133,142,228,228,228,228,228,228,160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 16 | .byte 160,32,160,160,244,160,233,160,160,160,228,228,132,137,147,139,148,143,143,140,228,228,228,228,160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 17 | .byte 160,32,160,160,244,160,95,160,160,160,228,228,228,133,152,129,141,144,140,133,228,228,228,228,160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 18 | .byte 160,32,160,160,205,239,160,160,160,160,228,228,228,228,144,146,143,135,146,129,141,228,228,228,160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 19 | .byte 160,32,251,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,236,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 20 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 21 | .byte 160,32,32,32,32,32,32,32,32,132,9,18,5,3,20,15,18,25,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 22 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 23 | .byte 160,32,32,32,32,32,32,32,32,137,14,9,20,9,1,12,9,26,5,32,4,9,19,11,32,40,16,1,18,20,32,57,41,32,32,32,32,32,32,32 24 | .byte 160,160,97,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 25 | .byte 160,226,126,32,32,147,1,22,5,32,4,1,20,1,32,32,150,9,5,23,32,4,1,20,1,32,32,18,133,19,20,15,18,5,32,4,1,20,1,32 26 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 27 | .byte 160,32,32,32,32,140,15,1,4,32,4,1,20,1,32,32,146,1,14,4,15,13,9,26,5,32,4,1,20,1,32,32,32,32,32,32,32,32,32,32 28 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 29 | .byte 160,32,32,32,32,32,32,32,32,133,18,1,19,5,32,6,9,12,5,32,40,16,1,18,20,32,57,41,32,32,32,32,32,32,32,32,32,32,32,32 30 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 31 | .byte 160,32,32,32,32,32,32,32,32,131,8,1,14,7,5,32,4,18,9,22,5,32,27,48,56,29,32,32,32,32,32,32,32,32,32,32,32,32,32,32 32 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,98,98,98,98,32,32,32,32,32,32,32,32,32,32,32 33 | .byte 160,32,32,32,32,32,32,32,32,19,148,1,20,21,19,32,32,32,32,32,32,32,32,108,255,160,160,160,160,127,123,32,32,32,32,32,32,32,32,32 34 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,255,160,254,160,160,252,160,127,32,32,32,32,32,32,32,32,32 35 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 36 | .byte 12,7,7,7,7,7,7,7,7,6,2,2,2,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,5,5,5,1,1,1,1,1,1,1,14,14 37 | .byte 12,14,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,1,1 38 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 39 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 40 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 41 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 42 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 43 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 44 | .byte 12,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 45 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 46 | .byte 12,14,14,14,14,14,14,14,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 47 | .byte 12,0,11,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 48 | .byte 12,11,11,14,14,14,14,14,14,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,14,11,11,11,11,11,14,11,11,14,14,14,14,14,14,14 49 | .byte 12,12,12,14,14,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 50 | .byte 12,12,12,14,14,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,1,1,1,1,1,1,1,1,1,1,1,1,14 51 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 52 | .byte 12,14,14,14,14,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14 53 | .byte 12,14,14,14,14,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 54 | .byte 12,14,14,14,14,14,14,14,14,11,11,11,11,11,11,11,11,11,11,14,11,11,11,11,11,14,11,11,14,14,14,14,14,14,14,14,14,14,14,14 55 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 56 | .byte 12,14,14,14,14,14,14,14,14,1,1,1,1,1,1,14,1,1,1,1,1,14,1,7,7,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14 57 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,12,12,12,12,14,14,14,14,14,14,14,14,14,14,14 58 | .byte 12,14,14,14,14,14,14,14,14,1,1,1,1,1,1,14,14,14,14,14,14,14,14,11,12,11,11,11,11,12,11,14,14,14,14,14,14,14,14,14 59 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,12,11,12,12,12,12,11,12,14,14,14,14,14,14,14,14,14 60 | .byte 12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 61 | -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/images/C64ProgrammingSeries-ep8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 08 - Disk Load and Save/images/C64ProgrammingSeries-ep8.jpg -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/images/ss1-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 08 - Disk Load and Save/images/ss1-2.jpg -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/images/ss1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 08 - Disk Load and Save/images/ss1.jpg -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/images/ss2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 08 - Disk Load and Save/images/ss2.jpg -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/images/ss3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 08 - Disk Load and Save/images/ss3.jpg -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/images/ss4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 08 - Disk Load and Save/images/ss4.jpg -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/load_address.bas: -------------------------------------------------------------------------------- 1 | 1 open 1,8,0,"filename,p" 2 | 2 get #1,a$,b$ 3 | 3 print asc(a$+chr$(0))+256*asc(b$+chr$(0)) 4 | 4 close1 5 | -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/prg_files/disktool.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 08 - Disk Load and Save/prg_files/disktool.prg -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/prg_files/disktool.sym: -------------------------------------------------------------------------------- 1 | .label draw_drive_number=$875 2 | .label drive_number_text=$88b 3 | .label displaydiskdata=$18f4 4 | .label skip2=$956 5 | .label screen_disk_tool=$1000 6 | .label filename=$17d3 7 | .label filename_length=$17e7 8 | .label mainloop=$893 9 | .label dir_presskey_text=$9b0 10 | .label diskdata=$17e8 11 | .label anykey_text=$990 12 | .label next=$954 13 | .label save_saving=$ae1 14 | .label getbyte=$9a2 15 | .label end=$9aa 16 | .label start=$827 { 17 | } 18 | .label dirname=$9af 19 | .label drive_number=$17d2 20 | .label dirname_end=$9b0 21 | .label init=$80d 22 | .label show_drive_status=$9bf 23 | .label exit=$97e 24 | .label copydiskdata=$18e8 25 | .label viewdiskdata=$1900 { 26 | } 27 | .label sds_loop=$9e0 28 | .label cfn_dont_add_s=$a92 29 | .label cfn_dont_add_l=$a1a 30 | .label char=$96c 31 | .label load_loading=$a61 32 | .label load_data=$9f2 { 33 | } 34 | .label randomizediskdata=$1924 35 | .label sds_devnp=$9f1 36 | .label show_directory=$926 { 37 | } 38 | .label error=$97e 39 | .label last_rand=$1938 40 | .label save_data=$a6a { 41 | } 42 | .label sds_eof=$9ed 43 | -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/prg_files/testdisk.d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 08 - Disk Load and Save/prg_files/testdisk.d64 -------------------------------------------------------------------------------- /Part 08 - Disk Load and Save/testdisk.d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 08 - Disk Load and Save/testdisk.d64 -------------------------------------------------------------------------------- /Part 09 - Disk Initialize and Erase File/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 9: Disk Format and Erase File plus Save Self Program 8 | https://youtu.be/8vL88ojy7FQ 9 | 10 | ![p9](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2009%20-%20Disk%20Initialize%20and%20Erase%20File/images/C64ProgrammingSeries-ep9.jpg) -------------------------------------------------------------------------------- /Part 09 - Disk Initialize and Erase File/diskdata.asm: -------------------------------------------------------------------------------- 1 | diskdata: 2 | .byte $43,'c','i','t','y','x','e','n',$43,$43,'d','i','s','k','t','o','o','l',$43,$3e,0,0,0,0,0,0,0,0,0,0,0,0 3 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 4 | .byte 0,0,0,'d','a','t','a',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 5 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 6 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,$53,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 7 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 8 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 9 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 10 | 11 | copydiskdata: 12 | ldx #$00 13 | !cpdd: 14 | lda diskdata,x 15 | sta data_start,x 16 | inx 17 | bne !cpdd- 18 | rts 19 | 20 | displaydiskdata: 21 | ldx #$00 22 | !ddd: 23 | lda data_start,x 24 | sta $0400+400,x 25 | inx 26 | bne !ddd- 27 | rts 28 | 29 | viewdiskdata: 30 | ClearScreen(BLACK) 31 | jsr displaydiskdata 32 | ldx #$00 33 | !vdd: 34 | lda dir_presskey_text,x 35 | beq !vdd+ 36 | jsr KERNAL_CHROUT 37 | inx 38 | jmp !vdd- 39 | !vdd: 40 | jsr KERNAL_WAIT_KEY 41 | beq !vdd- 42 | rts 43 | 44 | randomizediskdata: 45 | ldx #$00 46 | !rdd: 47 | lda $d41b // (get random number from SID) 48 | cmp last_rand // check to remove duplicates 49 | beq !rdd- 50 | sta last_rand 51 | sta data_start,x 52 | inx 53 | bne !rdd- 54 | rts 55 | last_rand: 56 | .byte 0 -------------------------------------------------------------------------------- /Part 09 - Disk Initialize and Erase File/disktool-program-screen.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | // PETSCII memory layout (example for a 40x25 screen)' 4 | // byte 0 = border color' 5 | // byte 1 = background color' 6 | // bytes 2-1001 = screencodes' 7 | // bytes 1002-2001 = color 8 | 9 | screen_disk_tool: 10 | .byte 0,0 11 | .byte 160,3,9,20,25,24,5,14,32,3,54,52,32,16,18,15,7,18,1,13,13,9,14,7,32,19,5,18,9,5,19,32,16,1,18,20,32,57,32,32 12 | .byte 160,32,4,9,19,11,32,6,15,18,13,1,20,32,1,14,4,32,5,18,1,19,5,32,6,9,12,5,32,43,32,19,1,22,5,32,16,18,7,32 13 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 14 | .byte 160,32,254,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,252,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 15 | .byte 160,32,160,160,206,247,160,160,160,160,228,131,137,148,153,152,133,142,228,228,228,228,228,228,160,32,131,8,1,14,7,5,32,4,18,9,22,5,32,32 16 | .byte 160,32,160,160,244,160,233,160,160,160,228,228,132,137,147,139,148,143,143,140,228,228,228,228,160,32,32,32,32,32,32,32,32,32,27,48,56,29,32,32 17 | .byte 160,32,160,160,244,160,95,160,160,160,228,228,228,133,152,129,141,144,140,133,228,228,228,228,160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 18 | .byte 160,32,160,160,205,239,160,160,160,160,228,228,228,228,144,146,143,135,146,129,141,228,228,228,160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 19 | .byte 160,32,251,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,236,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 20 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 21 | .byte 160,32,32,19,148,1,20,21,19,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 22 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 23 | .byte 160,32,32,32,132,9,18,5,3,20,15,18,25,32,32,32,32,32,32,32,32,32,150,9,5,23,32,4,1,20,1,32,32,32,32,32,32,32,32,32 24 | .byte 160,160,97,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 25 | .byte 160,226,126,32,137,14,9,20,9,1,12,9,26,5,32,4,9,19,11,32,32,18,133,19,20,15,18,5,32,4,1,20,1,32,32,32,32,32,32,32 26 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 27 | .byte 160,32,5,18,129,19,5,32,6,9,12,5,32,32,32,32,32,32,32,32,32,32,146,1,14,4,15,13,9,26,5,32,4,1,20,1,32,32,32,32 28 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 29 | .byte 160,32,32,32,147,1,22,5,32,4,1,20,1,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 30 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 31 | .byte 160,32,32,32,140,15,1,4,32,4,1,20,1,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 32 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,98,98,98,98,32,32,32,32,32,32,32,32,32,32,32 33 | .byte 160,32,32,32,151,18,9,20,5,32,16,18,15,7,18,1,13,32,32,32,32,32,32,108,254,160,160,160,160,252,123,32,32,32,32,32,32,32,32,32 34 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,254,160,160,226,226,160,160,252,32,32,32,32,32,32,32,32,32 35 | .byte 160,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,108,160,236,254,160,160,252,251,160,123,32,32,32,32,32,32,32,32 36 | .byte 6,7,7,7,7,7,7,7,7,6,2,2,2,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,5,5,5,1,1,1,1,1,1,1,14,14 37 | .byte 6,14,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,1 38 | .byte 6,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 39 | .byte 6,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 40 | .byte 6,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,5,1,1,1,1,1,14,1,1,1,1,1,14,14 41 | .byte 6,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,1,7,7,1,14,14 42 | .byte 6,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 43 | .byte 6,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 44 | .byte 6,14,6,6,6,6,6,6,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 45 | .byte 6,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 46 | .byte 6,14,14,1,5,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 47 | .byte 6,0,11,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 48 | .byte 6,11,11,14,5,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,5,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14 49 | .byte 6,6,12,14,14,14,14,14,1,1,14,14,14,14,1,1,1,1,14,14,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 50 | .byte 6,6,12,14,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,1,5,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14 51 | .byte 6,14,14,1,1,1,14,14,14,14,14,14,14,14,14,14,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 52 | .byte 6,14,1,1,5,1,1,1,1,1,1,1,14,14,11,14,11,11,11,14,1,1,5,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14 53 | .byte 6,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 54 | .byte 6,14,14,14,5,1,1,1,1,1,1,1,1,1,14,14,1,1,1,14,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14 55 | .byte 6,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 56 | .byte 6,14,14,14,5,1,1,1,1,1,1,1,1,1,14,14,14,11,11,14,14,14,14,14,14,14,14,14,14,14,14,14,11,14,14,14,14,14,14,14 57 | .byte 6,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,12,12,12,12,14,14,14,14,14,14,14,14,14,14,14 58 | .byte 6,1,14,14,5,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,11,12,11,11,11,11,12,11,14,1,14,14,14,14,14,14,14 59 | .byte 6,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,12,11,12,12,12,12,11,12,14,14,14,14,14,14,14,14,14 60 | .byte 6,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,1,14,14,14,14,14,12,11,12,6,6,6,6,12,11,12,14,14,14,14,14,14,14,14 61 | -------------------------------------------------------------------------------- /Part 09 - Disk Initialize and Erase File/erasefile.bas: -------------------------------------------------------------------------------- 1 | open 1,8,15,"s0:file":close 1 2 | -------------------------------------------------------------------------------- /Part 09 - Disk Initialize and Erase File/images/C64ProgrammingSeries-ep9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 09 - Disk Initialize and Erase File/images/C64ProgrammingSeries-ep9.jpg -------------------------------------------------------------------------------- /Part 09 - Disk Initialize and Erase File/images/ss1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 09 - Disk Initialize and Erase File/images/ss1.jpg -------------------------------------------------------------------------------- /Part 09 - Disk Initialize and Erase File/prg_files/disktool.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 09 - Disk Initialize and Erase File/prg_files/disktool.prg -------------------------------------------------------------------------------- /Part 09 - Disk Initialize and Erase File/prg_files/disktool.sym: -------------------------------------------------------------------------------- 1 | .label draw_drive_number=$875 2 | .label draw_confirm_question=$ccc 3 | .label format_disk=$b44 { 4 | } 5 | .label erase_file_confirm=$bc7 6 | .label formatdisk_confirm=$b35 7 | .label drive_number_text=$88b 8 | .label displaydiskdata=$210c 9 | .label skip2=$9b1 10 | .label screen_disk_tool=$1800 11 | .label filename=$1fd3 12 | .label writeprogram=$c66 { 13 | } 14 | .label fd_text_end=$ba5 15 | .label confirm_text=$cf4 16 | .label filename_length=$1fe7 17 | .label mainloop=$893 18 | .label ef_text=$c4a 19 | .label dir_presskey_text=$d35 20 | .label diskdata=$2000 21 | .label fd_cmd_end=$bc7 22 | .label ef_out=$c46 23 | .label anykey_text=$9eb 24 | .label ef_cpfn=$bea 25 | .label fd_loop2=$b38 26 | .label ef_cmd=$c51 27 | .label next=$9af 28 | .label save_saving=$b2d 29 | .label presskey=$d21 { 30 | } 31 | .label getbyte=$9fd 32 | .label prg_filename=$1fe8 33 | .label end=$a05 34 | .label start=$827 { 35 | } 36 | .label dirname=$a0a 37 | .label drive_number=$1fd2 38 | .label dirname_end=$a0b 39 | .label init=$80d 40 | .label show_drive_status=$a0b 41 | .label exit=$9d9 42 | .label copydiskdata=$2100 43 | .label ndc_loop=$cd0 44 | .label ef_cmd_end=$c66 45 | .label viewdiskdata=$2118 { 46 | } 47 | .label sds_loop=$a2c 48 | .label formatdisk=$b35 49 | .label cfn_dont_add_w=$c8e 50 | .label cfn_dont_add_s=$ade 51 | .label cfn_dont_add_l=$a66 52 | .label erasefile=$bc7 53 | .label efc_loop2=$bca 54 | .label char=$9c7 55 | .label efw_print1=$bfd 56 | .label efw_print2=$c0a 57 | .label erase_file=$bd6 { 58 | } 59 | .label fd_cmd=$ba5 60 | .label load_loading=$aad 61 | .label load_data=$a3e { 62 | } 63 | .label randomizediskdata=$213c 64 | .label ef_text_end=$c51 65 | .label sds_devnp=$a3d 66 | .label show_directory=$981 { 67 | } 68 | .label prg_filename_length=$1ff9 69 | .label error=$9d9 70 | .label last_rand=$2150 71 | .label fd_check_y_hit=$b3f 72 | .label save_data=$ab6 { 73 | } 74 | .label ef2_noerror=$c3e 75 | .label fd_text=$b95 76 | .label sds_eof=$a39 77 | .label fd_out=$b91 78 | .label efc_check_y_hit=$bd1 79 | -------------------------------------------------------------------------------- /Part 09 - Disk Initialize and Erase File/prg_files/testdisk.d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 09 - Disk Initialize and Erase File/prg_files/testdisk.d64 -------------------------------------------------------------------------------- /Part 10 - Simple IRQ Timers/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 10: Simple IRQ Timers 8 | https://www.youtube.com/watch?v=MUtG1zQOpFw 9 | 10 | ![p10](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2010%20-%20Simple%20IRQ%20Timers/images/C64ProgrammingSeries-ep10.jpg) -------------------------------------------------------------------------------- /Part 10 - Simple IRQ Timers/images/C64ProgrammingSeries-ep10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 10 - Simple IRQ Timers/images/C64ProgrammingSeries-ep10.jpg -------------------------------------------------------------------------------- /Part 10 - Simple IRQ Timers/prg_files/simple_irq_timers.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 10 - Simple IRQ Timers/prg_files/simple_irq_timers.prg -------------------------------------------------------------------------------- /Part 10 - Simple IRQ Timers/prg_files/simple_irq_timers.sym: -------------------------------------------------------------------------------- 1 | .label reset_timers=$84f 2 | .label start=$810 3 | .label irq_timer1=$885 4 | .label main=$82c 5 | .label irq_timer_trig2=$888 6 | .label irq_timer_trig1=$887 7 | .label irq_timer2=$886 8 | .label irq_timers=$85e 9 | -------------------------------------------------------------------------------- /Part 10 - Simple IRQ Timers/simple_irq_timers.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // CityXen Commodore 64 Programming Series Part 10 3 | // Simple Interrupt Request Timers 4 | // by Deadline 5 | // 6 | 7 | *=$0801 8 | BasicUpstart($0810) 9 | *=$0810 10 | 11 | start: 12 | 13 | jsr reset_timers 14 | 15 | sei 16 | lda #irq_timers 19 | sta $0315 20 | cli 21 | 22 | lda #$00 23 | sta $d020 24 | sta $d021 // clear background black 25 | lda #$93 // clear character 26 | jsr $ffd2 27 | 28 | main: 29 | 30 | lda irq_timer_trig1 // check to see if trigger 1 is set 31 | beq !ml+ 32 | inc $0400 // increment first screen mem loc 33 | lda #$00 34 | sta irq_timer_trig1 35 | sta irq_timer1 36 | 37 | !ml: 38 | 39 | lda irq_timer_trig2 // check to see if trigger 2 is set 40 | beq !ml+ 41 | inc $0401 // increment second screen mem loc 42 | lda #$00 43 | sta irq_timer_trig2 44 | sta irq_timer2 45 | 46 | !ml: 47 | 48 | jmp main 49 | 50 | reset_timers: 51 | lda #$00 52 | sta irq_timer1 53 | sta irq_timer2 54 | sta irq_timer_trig1 55 | sta irq_timer_trig2 56 | rts 57 | 58 | irq_timers: 59 | 60 | inc irq_timer1 61 | inc irq_timer2 62 | 63 | lda irq_timer1 64 | cmp #60 // 1 second 65 | bne !it+ 66 | inc irq_timer_trig1 67 | lda #$00 68 | sta irq_timer1 69 | 70 | !it: 71 | 72 | lda irq_timer2 73 | cmp #120 // 2 second 74 | bne !it+ 75 | inc irq_timer_trig2 76 | lda #$00 77 | sta irq_timer2 78 | 79 | !it: 80 | 81 | jmp $ea31 82 | 83 | // var space 84 | irq_timer1: 85 | .byte 0 86 | irq_timer2: 87 | .byte 0 88 | irq_timer_trig1: 89 | .byte 0 90 | irq_timer_trig2: 91 | .byte 0 92 | -------------------------------------------------------------------------------- /Part 11 - Funky BASIC Lines/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 11: Funky BASIC Lines 8 | https://www.youtube.com/watch?v=s6zRZKWNl7A 9 | 10 | ![p11](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2011%20-%20Funky%20BASIC%20Lines/images/C64PS-ep11.jpg) -------------------------------------------------------------------------------- /Part 11 - Funky BASIC Lines/funkybasic.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // CityXen Commodore 64 Programming Series Part 11 3 | // Funky BASIC Lines 4 | // by Deadline 5 | // 6 | 7 | #import "../include/Constants.asm" 8 | 9 | .file [name="funkybasic.prg", segments="Main"] 10 | 11 | .segment Main [allowOverlap] 12 | * = $0801 "BASIC Upstart" 13 | .word usend // link address 14 | .word 2024 // line number 15 | .byte $9e // BASIC Token for SYS 16 | .text toIntString(start) // start label to SYS to 17 | .text ":" 18 | .byte $80 // BASIC Token for END 19 | .text ":" 20 | .byte KEY_DELETE,KEY_DELETE,KEY_DELETE 21 | .byte KEY_DELETE,KEY_DELETE,KEY_DELETE 22 | .byte KEY_DELETE,KEY_DELETE,KEY_DELETE 23 | .byte KEY_DELETE,KEY_DELETE,KEY_DELETE 24 | .byte KEY_DELETE 25 | .text " -=*(CITYXEN)*=-" 26 | usend: 27 | .byte 0 28 | .word 0 // empty link signals the end of the program 29 | // THIS CODE IS FROM $0801 - $082c 30 | // The * directive below puts the code to $0830 31 | // well clear of any overlap 32 | // If you modify this code to change BASIC Upstart 33 | // and add more characters keep this in mind 34 | * = $0830 "init other things / vars / data" 35 | 36 | var_color1: 37 | .byte 0 38 | 39 | start: 40 | lda #$00 41 | sta $d020 42 | sta $d021 43 | lda #$00 44 | sta var_color1 45 | lp: 46 | lda var_color1 47 | sta $d020 48 | inc var_color1 49 | jmp lp 50 | 51 | 52 | -------------------------------------------------------------------------------- /Part 11 - Funky BASIC Lines/images/C64PS-ep11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 11 - Funky BASIC Lines/images/C64PS-ep11.jpg -------------------------------------------------------------------------------- /Part 11 - Funky BASIC Lines/prg_files/funkybasic.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 11 - Funky BASIC Lines/prg_files/funkybasic.prg -------------------------------------------------------------------------------- /Part 11 - Funky BASIC Lines/prg_files/funkybasic.sym: -------------------------------------------------------------------------------- 1 | .label start=$831 2 | .label lp=$83e 3 | .label usend=$82a 4 | .label var_color1=$830 5 | -------------------------------------------------------------------------------- /Part 12 - Long Text Scrollers - Zero Page/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 12: Long Text Scrollers (More than 256 Bytes) 8 | https://youtu.be/uI3EkZsTe9c 9 | 10 | ![p12](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2012%20-%20Long%20Text%20Scrollers%20-%20Zero%20Page/images/C64ProgrammingSeries-ep12.jpg) 11 | -------------------------------------------------------------------------------- /Part 12 - Long Text Scrollers - Zero Page/images/C64ProgrammingSeries-ep12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 12 - Long Text Scrollers - Zero Page/images/C64ProgrammingSeries-ep12.jpg -------------------------------------------------------------------------------- /Part 12 - Long Text Scrollers - Zero Page/long_text_scroller.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // CityXen Commodore 64 Programming Series Part 12 3 | // Long text scroller (More than 256 bytes) With 4 | // Color Cycling 5 | // Introduction to 6 | // Zero Page Indirect Indexed Addressing Mode 7 | ////////////////////////////////////////////////////////////////////// 8 | // 9 | // Indirect Indexed Addressing Mode 10 | // Two sequential bytes of zero page required 11 | // Y register is used to offset the result 12 | // Example 13 | // lda ($fb),y // errata in vid it is lda ($fb,y) 14 | // $fb=$52 15 | // $fc=$34 16 | // y register=$03 17 | // result: 18 | // accumulator will hold memory address $3455 19 | 20 | .const VIC_CONTROL_REG1 = $d011 21 | .const VIC_RASTER_COUNTER = $d012 22 | .const VIC_CONTROL_REG2 = $d016 23 | .const ZP_TMP = $fb 24 | .const ZP_TMP_LO = $fb 25 | .const ZP_TMP_HI = $fc 26 | .const SCREEN_BOTTOM_LEFT = $7c0 27 | .const SCREEN_BOTTOM_RIGHT= $7e7 28 | .const COLORS_BOTTOM_LEFT = $dbc0 29 | 30 | ///////////////////////////////////////////////// 31 | // START OF Programming 32 | 33 | *=$0801 "BASIC" 34 | :BasicUpstart($080d) 35 | *=$080d 36 | 37 | start: 38 | 39 | lda #$00 // clear screen black 40 | sta $d020 41 | sta $d021 42 | lda WHITE 43 | jsr $ffd2 44 | lda #$93 45 | jsr $ffd2 46 | 47 | jsr reset_message 48 | 49 | 50 | main: 51 | 52 | smc_label: 53 | lda #$00 // we'll modify the value of this address 54 | // making this by definition 55 | // self modifying code 56 | and #$07 57 | sta VIC_CONTROL_REG2 58 | 59 | loop2: 60 | lda #$ff 61 | cmp VIC_RASTER_COUNTER 62 | bne loop2 63 | 64 | lda #$c8 65 | sta VIC_CONTROL_REG2 66 | 67 | dec smc_label+1 68 | lda smc_label+1 69 | and #$07 70 | cmp #$07 71 | bne skipmove 72 | 73 | // move characters on the screen 74 | 75 | ldx #$00 76 | mvlp1: 77 | lda SCREEN_BOTTOM_LEFT+1,x // pull chars 78 | sta SCREEN_BOTTOM_LEFT,x // to the left 79 | inx 80 | cpx #39 // reached end of line? 81 | bne mvlp1 82 | 83 | // load next character from hello_message 84 | ldy #$00 85 | lda (ZP_TMP),y // use y register here and not x register 86 | cmp #$ff 87 | bne mvover1 88 | jsr reset_message 89 | lda #$20 90 | mvover1: 91 | sta SCREEN_BOTTOM_RIGHT 92 | inc ZP_TMP_LO // shift window to the right 93 | bne mvlp223 94 | inc ZP_TMP_HI 95 | mvlp223: 96 | 97 | skipmove: 98 | 99 | // cycle colors 100 | ldx #39 101 | cycle_colors: 102 | lda COLORS_BOTTOM_LEFT-1,x // pull color mem to the left 103 | sta COLORS_BOTTOM_LEFT,x 104 | dex 105 | cpx #$ff 106 | bne cycle_colors 107 | inc color_table_position 108 | ldx color_table_position 109 | lda color_table,x 110 | cmp #$ff 111 | beq reset_colors 112 | sta COLORS_BOTTOM_LEFT 113 | jmp main 114 | reset_colors: 115 | lda #$ff 116 | sta color_table_position 117 | jmp main 118 | 119 | reset_message: 120 | lda #hello_message 123 | sta ZP_TMP_HI 124 | rts 125 | 126 | hello_message: 127 | .encoding "screencode_upper" 128 | .text "LONG TEXT SCROLLER CODE BY DEADLINE " 129 | .text "CITYXEN COMMODORE 64 PROGRAMMING SERIES..." 130 | .text "PART 12, LONG TEXT SCROLLER & COLOR " 131 | .text "CYCLING " 132 | .text " " 133 | .text "CITYXEN PATRONS: " 134 | .text "-=*( SUTHEK )*=- " 135 | .text "-=*( OLAV HOPE )*=- " 136 | .text "-=*( PETZEL )*=- " 137 | .text "-=*( CREATE INVENT PODCAST )*=- " 138 | .text "-=*( 8 BIT SHOW & TELL )*=- " 139 | .text "-=*( JXYZN SXYZYXN )*=- " 140 | .text "-=*( GREGORY DUNLAP )*=- " 141 | .text "-=*( RAVENWOLF RETRO TECH )*=- " 142 | .text "-=*( KAREN EIDSON )*=- " 143 | .text "PATRON FREE MEMBERS " 144 | .text "-=*( RBGAMINGNETWORK )*=- " 145 | .text "-=*( BITBARN )*=- " 146 | .text "-=*( THANK YOU PATRONS! )*=- " 147 | .text " " 148 | .text "BECOME A PATRON TODAY, AND HAVE YOUR NAME " 149 | .text "BLASTED IN THIS SCROLLER IN EACH OF OUR FUTURE VIDEOS " 150 | .text " " 151 | .text " HTTPS://PATREON.COM/CITYXEN " 152 | 153 | .byte $ff 154 | 155 | color_table: 156 | .byte LIGHT_BLUE,BLUE,BLUE,BLUE,BLUE,BLUE,BLUE,BLUE,BLUE,BLUE,LIGHT_BLUE,LIGHT_BLUE,WHITE,LIGHT_BLUE 157 | .byte $ff 158 | 159 | // VARS 160 | // color_cycle_timer: // errata removed from vid version 161 | // .byte 0 // unneeded with demo shown 162 | color_table_position: 163 | .byte 0 164 | -------------------------------------------------------------------------------- /Part 12 - Long Text Scrollers - Zero Page/prg_files/long_text_scroller.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 12 - Long Text Scrollers - Zero Page/prg_files/long_text_scroller.prg -------------------------------------------------------------------------------- /Part 12 - Long Text Scrollers - Zero Page/prg_files/long_text_scroller.sym: -------------------------------------------------------------------------------- 1 | .label mvover1=$85b 2 | .label start=$80d 3 | .label loop2=$829 4 | .label main=$822 5 | .label reset_colors=$884 6 | .label color_table_position=$b9d 7 | .label mvlp223=$864 8 | .label color_table=$b8e 9 | .label mvlp1=$843 10 | .label hello_message=$895 11 | .label reset_message=$88c 12 | .label smc_label=$822 13 | .label skipmove=$864 14 | .label cycle_colors=$866 15 | -------------------------------------------------------------------------------- /Part 13 - Sound Effects Using Sound FX Kit/ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | This is the git repo to accompany the youtube series: Commodore 64 Programming by CityXen https://www.youtube.com/c/CityXen 6 | 7 | ### Part 13: Sound Effects Using The Sound FX Kit 8 | https://youtu.be/Akea-PGkgBc 9 | 10 | ![p13](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2013%20-%20Sound%20Effects%20Using%20Sound%20FX%20Kit/images/C64ProgrammingSeries-ep13.jpg) 11 | -------------------------------------------------------------------------------- /Part 13 - Sound Effects Using Sound FX Kit/images/C64ProgrammingSeries-ep13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 13 - Sound Effects Using Sound FX Kit/images/C64ProgrammingSeries-ep13.jpg -------------------------------------------------------------------------------- /Part 13 - Sound Effects Using Sound FX Kit/prg_files/soundeffects.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 13 - Sound Effects Using Sound FX Kit/prg_files/soundeffects.prg -------------------------------------------------------------------------------- /Part 13 - Sound Effects Using Sound FX Kit/prg_files/soundeffects.sym: -------------------------------------------------------------------------------- 1 | .label start=$810 2 | .label main=$813 3 | -------------------------------------------------------------------------------- /Part 13 - Sound Effects Using Sound FX Kit/sfxwdp.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 13 - Sound Effects Using Sound FX Kit/sfxwdp.prg -------------------------------------------------------------------------------- /Part 13 - Sound Effects Using Sound FX Kit/soundeffects.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // CityXen Commodore 64 Programming Series Part 13 3 | // Sound Effects using Sound FX Kit 4 | // by Deadline 5 | 6 | #import "../include/Constants.asm" 7 | 8 | *=$c000 "SFX KIT" 9 | .import binary "sfxwdp.prg", 2 10 | 11 | // FX PLAYER ON : sys 49152 : jsr $c000 // sound_on sr 12 | // FX PLAYER OFF : sys 49168 : jsr $c010 // sound_off sr 13 | // CLEAR REGISTERS : sys 49657 : jsr $c1f9 // clear sr 14 | // IRQ CONTROL : : jsr $c028 // add into irq 15 | 16 | *=$0801 17 | BasicUpstart($0810) 18 | *=$0810 19 | 20 | start: 21 | jsr $c000 22 | 23 | main: // main loop 24 | 25 | jsr KERNAL_GETIN 26 | cmp #KEY_1 27 | bne !m+ 28 | lda #$01 29 | sta $02a7 30 | !m: 31 | cmp #KEY_2 32 | bne !m+ 33 | lda #$02 34 | sta $02a7 35 | !m: 36 | cmp #KEY_3 37 | bne !m+ 38 | lda #$03 39 | sta $02a7 40 | !m: 41 | cmp #KEY_4 42 | bne !m+ 43 | lda #$04 44 | sta $02a7 45 | !m: 46 | cmp #KEY_5 47 | bne !m+ 48 | lda #$05 49 | sta $02a7 50 | !m: 51 | cmp #KEY_6 52 | bne !m+ 53 | lda #$06 54 | sta $02a7 55 | !m: 56 | jmp main 57 | -------------------------------------------------------------------------------- /Part 14 - RLE Compression/Part 14 - RLE Compression.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | }, 6 | { 7 | "path": "../include" 8 | }, 9 | { 10 | "path": "../Part 15 - RLE Crunch - DeCrunch" 11 | } 12 | ], 13 | "settings": {} 14 | } -------------------------------------------------------------------------------- /Part 14 - RLE Compression/PetmateScreenRLE.asm: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////// 2 | // 3 | // Petmate Screen - Adapted for Acme Compiler by KPK on 17-Apr-2024 4 | // 5 | // Converted back to KickAssembler 01-Feb-2025 by Deadline 6 | // 7 | /////////////////////////////////////////////////// 8 | 9 | .const zp_src = $fb // $fc 10 | .const zp_dest = $fd // $fe 11 | .const text_color = $0286 12 | .const screenram = $0400 13 | .const screen_data = $2000 14 | .const border_color = $d020 15 | .const bkgnd_color = $d021 16 | .const colorram = $d800 17 | .const chrout = $ffd2 18 | .const stop = $ffe1 19 | .const getin = $ffe4 20 | 21 | .const black = 0 22 | .const white = 1 23 | .const cls = 147 24 | 25 | * = $0801 // start of basic 26 | BasicUpstart2(start) 27 | * = $0830 "Start" 28 | start: 29 | lda #black 30 | sta border_color 31 | sta bkgnd_color 32 | lda #white 33 | sta text_color 34 | sta menuflag 35 | lda #cls 36 | jsr chrout 37 | jsr rle_decompress 38 | jsr write_instructions 39 | 40 | mainloop: 41 | jsr getin 42 | !: 43 | cmp #'1' 44 | bne !+ 45 | ldx #screen_data 47 | jsr drawpetmatescreen 48 | beq mainloop 49 | !: 50 | cmp #'2' 51 | bne !+ 52 | ldx #screen_data+2002 54 | jsr drawpetmatescreen 55 | beq mainloop 56 | !: 57 | cmp #'3' 58 | bne !+ 59 | ldx #screen_data+4004 61 | jsr drawpetmatescreen 62 | beq mainloop 63 | !: 64 | cmp #'4' 65 | bne !+ 66 | ldx #screen_data+6006 68 | jsr drawpetmatescreen 69 | beq mainloop 70 | !: 71 | cmp #'M' // toggle menu on or off 72 | bne !+ 73 | lda menuflag 74 | eor #$ff 75 | sta menuflag 76 | lda lastkey 77 | jmp !- 78 | !: 79 | jsr stop // check for stop key 80 | bne mainloop 81 | lda #cls 82 | jsr chrout 83 | lda #black 84 | sta border_color 85 | sta bkgnd_color 86 | rts 87 | 88 | drawpetmatescreen: 89 | sta lastkey 90 | stx zp_src 91 | sty zp_src+1 92 | ldy #$00 93 | lda (zp_src),y 94 | sta border_color 95 | iny 96 | lda (zp_src),y 97 | sta bkgnd_color 98 | dey 99 | lda zp_src 100 | clc 101 | adc #$02 102 | sta zp_src 103 | bcc !+ 104 | inc zp_src+1 105 | !: 106 | lda #screenram 109 | sta zp_dest+1 110 | ldx #$04 111 | !: 112 | lda (zp_src),y 113 | sta (zp_dest),y 114 | iny 115 | bne !- 116 | inc zp_src+1 117 | inc zp_dest+1 118 | dex 119 | bne !- 120 | lda zp_src // copy color data 121 | sec 122 | sbc #24 // skip 1000 bytes (1024 - 24) 123 | sta zp_src 124 | bcs !+ 125 | dec zp_src+1 126 | !: 127 | lda #colorram 130 | sta zp_dest+1 131 | ldx #$04 132 | !: 133 | lda (zp_src),y 134 | sta (zp_dest),y 135 | iny 136 | bne !- 137 | inc zp_src+1 138 | inc zp_dest+1 139 | dex 140 | bne !- 141 | jsr write_instructions 142 | rts 143 | 144 | write_instructions: 145 | lda menuflag 146 | and #1 147 | beq !++ 148 | ldx #0 149 | !: 150 | lda instructions,x 151 | beq !+ 152 | sta $07c4,x 153 | lda #white 154 | sta $dbc4,x 155 | inx 156 | bne !- 157 | !: 158 | rts 159 | 160 | rle_decompress: // decompress rle-encoded screen data 161 | lda #screen_data_rle 164 | sta zp_src+1 165 | lda #screen_data 168 | sta zp_dest+1 169 | rd1: 170 | ldy #0 171 | lda (zp_src),y 172 | beq rd2 173 | tax 174 | pha 175 | iny 176 | lda (zp_src),y 177 | dey 178 | !: 179 | sta (zp_dest),y 180 | iny 181 | dex 182 | bne !- 183 | pla 184 | clc 185 | adc zp_dest 186 | sta zp_dest 187 | bcc !+ 188 | inc zp_dest+1 189 | !: 190 | lda zp_src 191 | clc 192 | adc #2 193 | sta zp_src 194 | bcc !+ 195 | inc zp_src+1 196 | !: 197 | jmp rd1 198 | rd2: 199 | rts 200 | 201 | menuflag: 202 | .byte 1 203 | lastkey: 204 | .byte 1 205 | instructions: 206 | .text " press 1 to 4 to change screens " 207 | .byte 0 208 | * = $097e "ScreenData" 209 | #import "screendata_rle.asm" 210 | -------------------------------------------------------------------------------- /Part 14 - RLE Compression/original/PetmateScreenAcmeRLE.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 14 - RLE Compression/original/PetmateScreenAcmeRLE.zip -------------------------------------------------------------------------------- /Part 14 - RLE Compression/original/PetmateScreenAcmeRLE_original.asm: -------------------------------------------------------------------------------- 1 | ; Petmate Screen - Adapted for Acme Compiler by KPK on 17-Apr-2024 2 | 3 | !addr zp_src = $fb ; and $fc 4 | !addr zp_dest = $fd ; and $fe 5 | !addr text_color = $0286 6 | !addr screenram = $0400 7 | !addr screen_data = $2000 8 | !addr border_color = $d020 9 | !addr bkgnd_color = $d021 10 | !addr colorram = $d800 11 | !addr chrout = $ffd2 12 | !addr stop = $ffe1 13 | !addr getin = $ffe4 14 | 15 | black = 0 16 | white = 1 17 | cls = 147 18 | 19 | * = $0801 ; start of basic 20 | !pet 11,8,232,7,158,"2061",0,0,0 ; basic loader 21 | 22 | start: 23 | lda #black 24 | sta border_color 25 | sta bkgnd_color 26 | lda #white 27 | sta text_color 28 | sta menuflag 29 | lda #cls 30 | jsr chrout 31 | jsr rle_decompress 32 | jsr write_instructions 33 | 34 | mainloop: 35 | jsr getin 36 | - cmp #"1" 37 | bne + 38 | ldx #screen_data 40 | jsr drawpetmatescreen 41 | beq mainloop 42 | + cmp #"2" 43 | bne + 44 | ldx #screen_data+2002 46 | jsr drawpetmatescreen 47 | beq mainloop 48 | + cmp #"3" 49 | bne + 50 | ldx #screen_data+4004 52 | jsr drawpetmatescreen 53 | beq mainloop 54 | + cmp #"4" 55 | bne + 56 | ldx #screen_data+6006 58 | jsr drawpetmatescreen 59 | beq mainloop 60 | + cmp #"M" ; toggle menu on or off 61 | bne + 62 | lda menuflag 63 | eor #$ff 64 | sta menuflag 65 | lda lastkey 66 | jmp - 67 | + jsr stop ;check for stop key 68 | bne mainloop 69 | lda #cls 70 | jsr chrout 71 | lda #black 72 | sta border_color 73 | sta bkgnd_color 74 | rts 75 | 76 | drawpetmatescreen: 77 | sta lastkey 78 | stx zp_src 79 | sty zp_src+1 80 | ldy #$00 81 | lda (zp_src),y 82 | sta border_color 83 | iny 84 | lda (zp_src),y 85 | sta bkgnd_color 86 | dey 87 | lda zp_src 88 | clc 89 | adc #$02 90 | sta zp_src 91 | bcc + 92 | inc zp_src+1 93 | + lda #screenram 96 | sta zp_dest+1 97 | ldx #$04 98 | - lda (zp_src),y 99 | sta (zp_dest),y 100 | iny 101 | bne - 102 | inc zp_src+1 103 | inc zp_dest+1 104 | dex 105 | bne - 106 | lda zp_src ; copy color data 107 | sec 108 | sbc #24 ; skip 1000 bytes (1024 - 24) 109 | sta zp_src 110 | bcs + 111 | dec zp_src+1 112 | + lda #colorram 115 | sta zp_dest+1 116 | ldx #$04 117 | - lda (zp_src),y 118 | sta (zp_dest),y 119 | iny 120 | bne - 121 | inc zp_src+1 122 | inc zp_dest+1 123 | dex 124 | bne - 125 | jsr write_instructions 126 | rts 127 | 128 | write_instructions: 129 | lda menuflag 130 | and #1 131 | beq + 132 | ldx #0 133 | - lda instructions,x 134 | beq + 135 | sta $07c4,x 136 | lda #white 137 | sta $dbc4,x 138 | inx 139 | bne - 140 | + rts 141 | 142 | rle_decompress: ; decompress rle-encoded screen data 143 | lda #screen_data_rle 146 | sta zp_src+1 147 | lda #screen_data 150 | sta zp_dest+1 151 | -- ldy #0 152 | lda (zp_src),y 153 | beq ++ 154 | tax 155 | pha 156 | iny 157 | lda (zp_src),y 158 | dey 159 | - sta (zp_dest),y 160 | iny 161 | dex 162 | bne - 163 | pla 164 | clc 165 | adc zp_dest 166 | sta zp_dest 167 | bcc + 168 | inc zp_dest+1 169 | + lda zp_src 170 | clc 171 | adc #2 172 | sta zp_src 173 | bcc + 174 | inc zp_src+1 175 | + jmp -- 176 | ++ rts 177 | 178 | menuflag: !byte 1 179 | lastkey: !fill 1 180 | instructions: !scr " press 1 to 4 to change screens ",0 181 | !src "screendata_rle.asm" -------------------------------------------------------------------------------- /Part 14 - RLE Compression/original/rle_compress.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 14 - RLE Compression/original/rle_compress.prg -------------------------------------------------------------------------------- /Part 14 - RLE Compression/original/rle_compress_original.asm: -------------------------------------------------------------------------------- 1 | ; Perform basic RLE compression on data - 17-Apr-2024 by KPK 2 | 3 | !addr zp_src = $fb ; and $fc 4 | !addr zp_dest = $fd ; and $fe 5 | !addr strout = $ab1e 6 | !addr line_print = $bdcd 7 | !addr rle_data = $3000 8 | !addr chrout = $ffd2 9 | 10 | * = $0801 ; start of basic 11 | !pet 11,8,232,7,158,"2061",0,0,0 ; basic loader 12 | 13 | ; ********************************************************* 14 | 15 | start: 16 | jsr generate_rle_data 17 | jsr show_stats 18 | rts 19 | 20 | generate_rle_data: 21 | lda #screen_data 24 | sta zp_src+1 25 | lda #rle_data 28 | sta zp_dest+1 29 | ldy #0 30 | lda (zp_src),y 31 | sta rle_byte 32 | inc rle_count 33 | inc zp_src 34 | 35 | gr_loop: 36 | lda (zp_src),y 37 | cmp rle_byte 38 | bne gr_diff 39 | 40 | gr_same: 41 | lda rle_count 42 | cmp #255 43 | bne gr_next 44 | 45 | gr_diff: 46 | lda rle_count 47 | sta (zp_dest),y 48 | lda rle_byte 49 | iny 50 | sta (zp_dest),y 51 | dey 52 | lda (zp_src),y 53 | sta rle_byte 54 | lda #0 55 | sta rle_count 56 | clc 57 | lda zp_dest 58 | adc #2 59 | sta zp_dest 60 | bcc gr_next 61 | inc zp_dest+1 62 | 63 | gr_next: 64 | inc rle_count 65 | inc zp_src 66 | bne + 67 | inc zp_src+1 68 | + lda zp_src+1 69 | cmp #>end_of_data+1 70 | bcc gr_loop 71 | lda zp_src 72 | cmp #msg1 93 | jsr strout 94 | ldx #rle_data 96 | jsr line_print 97 | lda #"-" 98 | jsr chrout 99 | lda zp_dest 100 | clc 101 | adc #3 102 | sta zp_dest 103 | bcc + 104 | inc zp_dest+1 105 | + ldx zp_dest 106 | lda zp_dest+1 107 | jsr line_print 108 | lda #msg2 110 | jsr strout 111 | lda #>rle_data 112 | jsr print_hex 113 | lda #screen_data 29 | sta zp_src+1 30 | lda #rle_data 33 | sta zp_dest+1 34 | ldy #0 35 | lda (zp_src),y 36 | sta rle_byte 37 | inc rle_count 38 | inc zp_src 39 | 40 | gr_loop: 41 | lda (zp_src),y 42 | cmp rle_byte 43 | bne gr_diff 44 | 45 | gr_same: 46 | lda rle_count 47 | cmp #255 48 | bne gr_next 49 | 50 | gr_diff: 51 | lda rle_count 52 | sta (zp_dest),y 53 | lda rle_byte 54 | iny 55 | sta (zp_dest),y 56 | dey 57 | lda (zp_src),y 58 | sta rle_byte 59 | lda #0 60 | sta rle_count 61 | clc 62 | lda zp_dest 63 | adc #2 64 | sta zp_dest 65 | bcc gr_next 66 | inc zp_dest+1 67 | 68 | gr_next: 69 | inc rle_count 70 | inc zp_src 71 | bne !+ 72 | inc zp_src+1 73 | !: 74 | lda zp_src+1 75 | cmp #>end_of_data+1 76 | bcc gr_loop 77 | lda zp_src 78 | cmp #msg1 100 | jsr strout 101 | ldx #rle_data 103 | jsr line_print 104 | lda #'-' 105 | jsr chrout 106 | lda zp_dest 107 | clc 108 | adc #3 109 | sta zp_dest 110 | bcc !+ 111 | inc zp_dest+1 112 | !: 113 | ldx zp_dest 114 | lda zp_dest+1 115 | jsr line_print 116 | lda #msg2 118 | jsr strout 119 | lda #>rle_data 120 | jsr print_hex 121 | lda # $v) { 9 | 10 | $tv=str_split($v,2); 11 | foreach($tv as $tkk => $tvv) { 12 | $kr=$tv; 13 | $tv[$tkk]="$".$tvv.","; 14 | echo " $kr -> $tvv"; 15 | } 16 | echo "\n"; 17 | $jv=join($tv); 18 | 19 | fputs($fo,$jv,strlen($jv)); 20 | fputs($fo,"\n",1); 21 | 22 | } 23 | fclose($fo); 24 | -------------------------------------------------------------------------------- /Part 15 - RLE Crunch - DeCrunch/prg_files/rle-crunch.d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 15 - RLE Crunch - DeCrunch/prg_files/rle-crunch.d64 -------------------------------------------------------------------------------- /Part 15 - RLE Crunch - DeCrunch/prg_files/rle-crunch.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 15 - RLE Crunch - DeCrunch/prg_files/rle-crunch.prg -------------------------------------------------------------------------------- /Part 15 - RLE Crunch - DeCrunch/prg_files/rle-crunch.sym: -------------------------------------------------------------------------------- 1 | .label h2vend=$1158 2 | .label il_it2_kb_chk_del_first_pos=$f4b 3 | .label file_loc_end_hi=$ae3 4 | .label il_it2_txt_len=$ea4 5 | .label draw_drive_number=$b06 6 | .label il_it2_trim=$f85 7 | .label print_leading_zeros_as_spaces=$8dd 8 | .label save_file=$b56 9 | .label drive_number_text=$98e 10 | .label skip2=$c88 11 | .label file_size_lo=$ae5 12 | .label screencode_to_petscii=$876 13 | .label load_address_end_hi=$afa 14 | .label device_not_present_text=$96b 15 | .label zstr_src=$157a 16 | .label rd1=$da3 17 | .label rd2=$dcd 18 | .label byte_srcfile_len=$1190 19 | .label wlz=$8cd 20 | .label il_it2_txt_color_hi=$ea3 21 | .label filename_length=$9bd 22 | .label il_it2_kb_num=$f5c 23 | .label load_file_file_loc=$b1c 24 | .label sdsskip=$c2c 25 | .label j1_left=$de8 26 | .label main_loop=$14df 27 | .label strbuf=$fb9 28 | .label wlyz=$8d4 29 | .label j1_down=$de7 30 | .label int_acc=$10df 31 | .label STR_PRESSKEY=$10c8 32 | .label load_address_end=$af9 33 | .label file_loc_end_lo=$ae2 34 | .label sdseof=$c49 35 | .label anykey_text=$cc7 36 | .label string_destfile=$1191 37 | .label sc2p_sub64=$898 38 | .label file_size_hi=$ae4 39 | .label j1_button=$dea 40 | .label load_address_end_lo=$af9 41 | .label nzp1=$8a9 42 | .label rle_data_size=$ce8 43 | .label add_value=$1147 44 | .label use_file_loc=$ade 45 | .label sc2p_add0=$8a2 46 | .label zstr_data_size=$15a0 47 | .label rle_data=$cec 48 | .label str_len=$fb8 49 | .label zstr_rle_data_size=$1591 50 | .label end=$ce1 51 | .label j2_up=$e03 52 | .label msg2=$15b8 53 | .label msg1=$15ab 54 | .label hex_cvrt=$112b 55 | .label j2_right=$e06 56 | .label print=$811 57 | .label rle_set_dest=$cee 58 | .label print_no_leading_zeros=$8a3 59 | .label il_get_any_input=$e21 60 | .label y_reg=$dd0 61 | .label zstr_loadin=$155b 62 | .label sdserror=$c52 63 | .label wtf=$80e 64 | .label il_it2_txt_loc=$e9f 65 | .label rle_count=$cea 66 | .label sc2p_add128=$89c 67 | .label show_drive_status=$c16 68 | .label exit=$cb0 69 | .label open_file_get_one_byte=$bad 70 | .label zstr_crunching=$1584 71 | .label j1_up=$de6 72 | .label sds_loop=$bf9 73 | .label il_it2_reverse=$ee7 74 | .label hex_tmp=$10de 75 | .label gr_next=$d53 76 | .label filename_buffer=$9be 77 | .label file_size=$ae4 78 | .label il_it2_kb_chk=$efe 79 | .label il_it2_cursor=$ec6 80 | .label sdsloop=$c3b 81 | .label print_r_out=$85e 82 | .label tmp_1=$dd1 83 | .label tmp_3=$dd3 84 | .label k_value=$ddc 85 | .label tmp_2=$dd2 86 | .label sc2p_add64=$89f 87 | .label il_it2_kb_chk_no_crs=$f19 88 | .label il_it2_kb_not_too_long=$f28 89 | .label show_directory=$c55 90 | .label print_hex_inline_conversion_table=$940 91 | .label buf_crsr=$10b9 92 | .label ascii_to_petscii_kp=$86b 93 | .label il_get_key=$ddd 94 | .label input_text2=$ec7 95 | .label il_it2_txt_color_lo=$ea2 96 | .label file_loc=$ae0 97 | .label zstr_dst=$157f 98 | .label string_title=$115c 99 | .label gr_loop=$d1e 100 | .label il_it2_txt_scr=$e9d 101 | .label il_get_j1_m2=$deb 102 | .label byte_destfile_len=$11a3 103 | .label filename=$9be 104 | .label hexstr16_to_val=$10e0 105 | .label a_reg=$dce 106 | .label sec_command=$adf 107 | .label il_it2_buffer=$ea5 108 | .label save_addr_end=$14e2 109 | .label get_any_input=$e21 110 | .label i_compare=$e20 111 | .label gr_diff=$d2c 112 | .label print_out=$824 113 | .label print_hex=$950 114 | .label pr1=$828 115 | .label nzsp1=$8e3 116 | .label get_j2_m2=$e08 117 | .label rle_byte=$ceb 118 | .label get_key=$ddd 119 | .label string_enter_dest=$11b8 120 | .label il_it2_out=$f9e 121 | .label il_it2_kb_chk_not_del=$f56 122 | .label show_drive_status2=$bd8 123 | .label x_reg=$dcf 124 | .label zpnzp_c=$91c 125 | .label rle_data_size_lo=$ce8 126 | .label ascii_to_petscii=$860 127 | .label zeroize_filename_buffer=$afb 128 | .label next=$c86 129 | .label il_it2_kb_chk_end=$f6b 130 | .label get_j1_m2=$deb 131 | .label j2_left=$e05 132 | .label dirpause=$ce7 133 | .label save_saving=$aed 134 | .label file_loc_end=$ae2 135 | .label getbyte=$cd9 136 | .label device_not_present_text2=$97f 137 | .label string_copy_2=$fb7 138 | .label string_copy_1=$fa2 139 | .label il_get_j2_m2=$e08 140 | .label start=$11e0 141 | .label il_it2_txt_loc_lo=$e9f 142 | .label file_loc_lo=$ae0 143 | .label j1_right=$de9 144 | .label rle_set_src=$cf3 145 | .label dirname=$ce6 146 | .label sdsclose=$c49 147 | .label string_copy=$f9f 148 | .label wlysz=$913 149 | .label drive_number=$9bc 150 | .label string_srcfile=$117e 151 | .label dirname_end=$ce7 152 | .label il_it2_txt_scr_hi=$e9e 153 | .label il_it2_kb_chk_crs_not_revd=$f15 154 | .label is_hex=$113c 155 | .label zstr_minus_dollar=$1577 156 | .label print_rainbow=$825 157 | .label rle_data_size_hi=$ce9 158 | .label print_hex_inline_d=$91d 159 | .label zero_strbuf=$10ba 160 | .label hex_val=$10dc 161 | .label il_it2_txt_color=$ea2 162 | .label print_hex_inline=$91e 163 | .label j2_down=$e04 164 | .label il_it2_txt_loc_hi=$ea0 165 | .label char=$c9e 166 | .label file_loc_hi=$ae1 167 | .label save_addr=$14e0 168 | .label rle_compress=$d02 169 | .label save_record_over_string=$af5 170 | .label inc_rle_data_size=$cf8 171 | .label gr_same=$d25 172 | .label string_enter_src=$11a4 173 | .label il_it2_txt_scr_lo=$e9d 174 | .label load_loading=$ae6 175 | .label string_hex=$10d7 176 | .label il_it2_txt_color_val=$ea1 177 | .label print_h_digit=$95f 178 | .label sds_devnp=$c0a { 179 | } 180 | .label print_r_t=$85f 181 | .label rle_decompress=$da3 182 | .label sc2p_sub128=$895 183 | .label show_stats=$14e4 184 | .label string_specify_load_address=$11cc 185 | .label wlsz=$90c 186 | .label error=$cb0 187 | .label wait_vbl=$dd4 188 | .label save_data=$b82 189 | .label zstr_savin_2=$1573 190 | .label il_it2_rereverse=$f74 191 | .label j2_button=$e07 192 | .label sds_eof=$c06 193 | .label zstr_savin_1=$156a 194 | .label load_file=$b1c 195 | .label il_it2_buffer_end=$ec5 196 | -------------------------------------------------------------------------------- /Part 15 - RLE Crunch - DeCrunch/prg_files/screens.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 15 - RLE Crunch - DeCrunch/prg_files/screens.prg -------------------------------------------------------------------------------- /Part 15 - RLE Crunch - DeCrunch/prg_files/screens.sym: -------------------------------------------------------------------------------- 1 | .label screen_004=$4776 2 | .label screen_003=$3fa4 3 | .label screen_002=$37d2 4 | .label screen_001=$3000 5 | -------------------------------------------------------------------------------- /Part 15 - RLE Crunch - DeCrunch/rle-decrunch.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/Part 15 - RLE Crunch - DeCrunch/rle-decrunch.asm -------------------------------------------------------------------------------- /Part 15 - RLE Crunch - DeCrunch/screens.asm: -------------------------------------------------------------------------------- 1 | * = $3000 "Screens" 2 | #import "screendata.asm" 3 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # 🌆🅲🅸🆃🆈🆇🅴🅽☯️ 8 & 16 bit hijinx and programming! 2 | 3 | # Commodore 64 Programming 4 | 5 | include folder contains files you can import to make programming the Commodore 64 easier. 6 | 7 | ## Commodore 64 Programming Series on YouTube 8 | 9 | Commodore 64 Programming Series on YouTube by CityXen https://youtube.com/CityXen 10 | 11 | ### Part 1: Setting up KickAssembler and VSCode on Windows10 12 | https://youtu.be/R9VE2U_p060 13 | 14 | ![p1](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2001%20-%20Setup%20KickAssembler%20and%20VSCode/C64ProgrammingSeries-ep1.jpg) 15 | 16 | ### Part 2: Hello World 17 | https://youtu.be/017LMlEqUO4 18 | 19 | ![p2](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2002%20-%20Hello%20World/images/C64ProgrammingSeries-ep2.jpg) 20 | 21 | ### Part 3: Sinus Sprites 22 | https://youtu.be/-UmPO8koghQ 23 | 24 | ![p3](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2003%20-%20Sinus%20Sprites/images/C64ProgrammingSeries-ep3.jpg) 25 | 26 | ### Part 4: Custom Characters, Smooth Scrolling & Macros 27 | https://youtu.be/eDrUNJQrAnU 28 | 29 | ![p4](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2004%20-%20Custom%20Chars%2C%20Smooth%20Scrolling/images/C64ProgrammingSeries-ep4.jpg) 30 | 31 | ### Part 5: Horizontal Scroller Message, Multicolor Characters & Raster line changes 32 | https://youtu.be/2EbZP9kp4zE 33 | 34 | ![p5](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2005%20-%20Scroller%20Message/images/C64ProgrammingSeries-ep5.jpg) 35 | 36 | ### Part 6: Petmate Screens and Keyboard Reading 37 | https://youtu.be/XYHfms1-3Yo 38 | 39 | ![p6](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2006%20-%20Petmate%20Screens%20and%20Keyboard/images/C64ProgrammingSeries-ep6.jpg) 40 | 41 | ### Part 7: Disk Status and Directory 42 | https://youtu.be/t-hzeeFpD8c 43 | 44 | ![p7](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2007%20-%20Disk%20Status%20and%20Directory/images/C64ProgrammingSeries-ep7.jpg) 45 | 46 | ### Part 8: Disk Load and Save + SID Random Number Generation 47 | https://youtu.be/Zd19AuajTdQ 48 | 49 | ![p8](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2008%20-%20Disk%20Load%20and%20Save/images/C64ProgrammingSeries-ep8.jpg) 50 | 51 | ### Part 9: Disk Format and Erase File plus Save Self Program 52 | https://youtu.be/8vL88ojy7FQ 53 | 54 | ![p9](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2009%20-%20Disk%20Initialize%20and%20Erase%20File/images/C64ProgrammingSeries-ep9.jpg) 55 | 56 | ### Part 10: Simple IRQ Timers 57 | https://www.youtube.com/watch?v=MUtG1zQOpFw 58 | 59 | ![p10](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2010%20-%20Simple%20IRQ%20Timers/images/C64ProgrammingSeries-ep10.jpg) 60 | 61 | ### Part 11: Funky BASIC Lines 62 | https://www.youtube.com/watch?v=s6zRZKWNl7A 63 | 64 | ![p11](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2011%20-%20Funky%20BASIC%20Lines/images/C64PS-ep11.jpg) 65 | 66 | ### Part 12: Long Text Scrollers (More than 256 Bytes) 67 | https://youtu.be/uI3EkZsTe9c 68 | 69 | ![p12](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2012%20-%20Long%20Text%20Scrollers%20-%20Zero%20Page/images/C64ProgrammingSeries-ep12.jpg) 70 | 71 | ### Part 13: Sound Effects Using The Sound FX Kit 72 | https://youtu.be/Akea-PGkgBc 73 | 74 | ![p13](https://github.com/cityxen/Commodore64_Programming/blob/master/Part%2013%20-%20Sound%20Effects%20Using%20Sound%20FX%20Kit/images/C64ProgrammingSeries-ep13.jpg) 75 | -------------------------------------------------------------------------------- /include/CityXenLib.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | #import "Constants.asm" 10 | #import "Macros.asm" 11 | //#import "Music.asm" 12 | #import "DrawPetMateScreen.asm" 13 | -------------------------------------------------------------------------------- /include/CityXenLibCode.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | -------------------------------------------------------------------------------- /include/DrawPetMateScreen.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | .macro DrawPetMateScreen(screen_name) { 10 | //////////////////////////////////////////////// 11 | // Draw the Petmate Screen... START 12 | lda screen_name 13 | sta BORDER_COLOR 14 | lda screen_name+1 15 | sta BACKGROUND_COLOR 16 | ldx #$00 // Draw the screen from memory location 17 | !dpms_loop: 18 | lda screen_name+2,x // Petmate screen (+2 is to skip over background/border color) 19 | sta 1024,x 20 | lda screen_name+2+256,x 21 | sta 1024+256,x 22 | lda screen_name+2+512,x 23 | sta 1024+512,x 24 | lda screen_name+1000+2,x 25 | sta COLOR_RAM,x // And now the colors 26 | lda screen_name+1000+2+256,x 27 | sta COLOR_RAM+256,x 28 | lda screen_name+1000+2+512,x 29 | sta COLOR_RAM+512,x 30 | inx 31 | bne !dpms_loop- 32 | ldx #232 33 | !dpms_loop: // fix overwriting sprite pointers loop 34 | dex 35 | lda screen_name+2+512+256,x 36 | sta 1024+512+256,x 37 | lda screen_name+1000+2+512+256,x 38 | sta COLOR_RAM+512+256,x 39 | cpx #$00 40 | bne !dpms_loop- 41 | // Draw the Petmate Screen... END 42 | //////////////////////////////////////////////// 43 | } -------------------------------------------------------------------------------- /include/Macros.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | ////////////////////////////////////////////////////////////////// 10 | // 11 | // Notes: 12 | // - Must include Constants.asm before include Macros.asm 13 | // - These macros are intended for one time use only, each time you add macro 14 | // it increases size of prg. Therefore use sparingly. If you need something 15 | // that does these over and over, consider making an actual routine that you 16 | // can jsr to. 17 | // 18 | ////////////////////////////////////////////////////////////////// 19 | 20 | #import "Constants.asm" 21 | 22 | .macro ClearScreen(color) { 23 | lda #$93 24 | jsr KERNAL_CHROUT // $FFD2 25 | lda #color 26 | sta BACKGROUND_COLOR // $D020 27 | sta BORDER_COLOR // $D021 28 | } 29 | 30 | .macro ClearScreenB(color,bcolor) { 31 | lda #$93 32 | jsr KERNAL_CHROUT // $FFD2 33 | lda #color 34 | sta BACKGROUND_COLOR // $D020 35 | lda #bcolor 36 | sta BORDER_COLOR // $D021 37 | sta 646 38 | } 39 | 40 | .macro ClearScreenColors(color,bcolor) { 41 | ClearScreen(color) 42 | ldx #$00 43 | lda bcolor 44 | !loop: 45 | sta COLOR_RAM,x 46 | sta COLOR_RAM+256,x 47 | sta COLOR_RAM+512,x 48 | sta COLOR_RAM+512+256,x 49 | inx 50 | cpx #$006 51 | bne !loop- 52 | } 53 | 54 | .macro SetCharacters(value) { 55 | lda VIC_MEM_POINTERS // point to the new characters 56 | .var p=value/$400 57 | ora #p 58 | sta VIC_MEM_POINTERS 59 | } 60 | 61 | .macro PokeString(loc,string_loc) { 62 | ldx #$00 63 | !loop: 64 | lda string_loc,x 65 | beq !loop+ 66 | sta loc,x 67 | inx 68 | jmp !loop- 69 | !loop: 70 | } 71 | 72 | .macro PokeStringColor(loc,string_loc,color) { 73 | .var color_ram=COLOR_RAM 74 | !loop: 75 | .var color_loc=COLOR_RAM 76 | .var rainbow=false 77 | .if(color!="RAINBOW") { 78 | .eval color_loc=color_ram+(loc-1024) 79 | } 80 | .if(color=="RAINBOW") { 81 | .eval color=BLACK 82 | .eval color_loc=color_ram+(loc-1024) 83 | .eval rainbow=true 84 | } 85 | lda #color 86 | sta color_lbl 87 | ldx #$00 88 | !loop: 89 | .if(rainbow==true) inc color_lbl 90 | lda string_loc,x 91 | beq !loop+ 92 | sta loc,x 93 | lda color_lbl 94 | sta color_loc,x 95 | inx 96 | jmp !loop- 97 | !loop: 98 | jmp !loop+ 99 | color_lbl: 100 | nop 101 | !loop: 102 | } 103 | 104 | .macro ReadKeyJSR(x,sbr) { 105 | !check_key: 106 | cmp #x 107 | bne !check_key+ 108 | jsr sbr 109 | !check_key: 110 | } 111 | 112 | .macro ReadKeyJMP(x,sbr) { 113 | !check_key: 114 | cmp #x 115 | bne !check_key+ 116 | jmp sbr 117 | !check_key: 118 | } 119 | 120 | .macro ReadJoyJSR(joy,dir,sbr) { 121 | lda #joy 122 | cmp #$01 123 | beq !check_joy+ 124 | lda $DC00 125 | jmp !check_joy++ 126 | !check_joy: 127 | lda $DC01 128 | !check_joy: 129 | .if (dir=="UP") .eval dir=1 130 | .if (dir=="DOWN") .eval dir=2 131 | .if (dir=="LEFT") .eval dir=4 132 | .if (dir=="RIGHT") .eval dir=8 133 | .if (dir=="FIRE") .eval dir=16 134 | and #dir 135 | bne !check_joy+ 136 | jsr sbr 137 | !check_joy: 138 | } 139 | 140 | .macro ReadJoyJMP(joy,dir,sbr) { 141 | lda #joy 142 | cmp #$01 143 | beq !check_joy+ 144 | lda $DC00 145 | jmp !check_joy++ 146 | !check_joy: 147 | lda $DC01 148 | !check_joy: 149 | .if (dir=="UP") .eval dir=1 150 | .if (dir=="DOWN") .eval dir=2 151 | .if (dir=="LEFT") .eval dir=4 152 | .if (dir=="RIGHT") .eval dir=8 153 | .if (dir=="FIRE") .eval dir=16 154 | and #dir 155 | bne !check_joy+ 156 | jmp sbr 157 | !check_joy: 158 | } 159 | 160 | .macro CityXenUpstart(start) { 161 | 162 | // .segment Main [allowOverlap] 163 | * = $0801 "BASIC Upstart" 164 | .word usend // link address 165 | .word 2025 // line num (Current Year) 166 | .byte $9e // sys 167 | .text toIntString(start) // This is start label in main program 168 | .text ":" 169 | .byte $80 // end 170 | .text ":" 171 | .byte KEY_DELETE,KEY_DELETE,KEY_DELETE,KEY_DELETE 172 | .byte KEY_DELETE,KEY_DELETE,KEY_DELETE,KEY_DELETE 173 | .byte KEY_DELETE,KEY_DELETE,KEY_DELETE,KEY_DELETE 174 | .byte KEY_DELETE 175 | .text " -=*(CITYXEN)*=-" 176 | usend: 177 | .byte 0 178 | .word 0 // empty link signals the end of the program 179 | // THIS CODE IS FROM $0801 - $082C 180 | // The * directive below puts the code to $0830 181 | // well clear of any allowOverlap 182 | // If you modify this to change the BASIC Upstart 183 | // and add more characters keep this in mind 184 | * = $0830 "vars and lib init" 185 | 186 | } 187 | 188 | .macro zp_str(x) { 189 | lda #x 192 | sta zp_tmp_hi 193 | } 194 | -------------------------------------------------------------------------------- /include/Music.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | .macro InitializeMusic(music_option) { 10 | lda #$01 11 | sta music_option 12 | ldx #0 13 | ldy #0 14 | lda #00 15 | jsr music.init 16 | lda #$7f 17 | sta $dc0d 18 | lda $dc0d 19 | sei 20 | lda #$01 21 | sta VIC_INTERRUPT_ENABLE 22 | lda #$44 23 | sta VIC_RASTER_COUNTER 24 | lda $d011 25 | and #$7f 26 | sta $d011 27 | lda #irq1 30 | sta $0315 31 | cli 32 | } 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /include/honkheckbutt.il.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | .const BUTTON_RED = $FB 10 | .const BUTTON_GREEN = $FE 11 | .const BUTTON_YELLOW = $FD 12 | .const BUTTON_BLUE = $F7 13 | .const BUTTON_WHITE = $EF 14 | 15 | .const BUTTON_LIGHT_GREEN = %11111110 16 | .const BUTTON_LIGHT_YELLOW = %11111101 17 | .const BUTTON_LIGHT_BLUE = %11111011 18 | .const BUTTON_LIGHT_RED = %11110111 19 | .const BUTTON_LIGHT_WHITE = %10111111 20 | .const BUTTON_LIGHT_ALL = %00000000 21 | .const BUTTON_LIGHT_NONE = %11111111 22 | 23 | hhb_set_lights: 24 | sta USER_PORT_DATA 25 | rts -------------------------------------------------------------------------------- /include/music.il.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | #define CONFIG_MUSIC -------------------------------------------------------------------------------- /include/print.il.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | #importonce 10 | 11 | #import "print/print.asm" 12 | #import "print/print_ascii_to_petscii.asm" 13 | #import "print/print_screencode_to_petscii.asm" 14 | #import "print/print_no_leading_zeros.asm" 15 | #import "print/print_leading_zeros_as_spaces.asm" 16 | #import "print/print_hex.asm" 17 | 18 | -------------------------------------------------------------------------------- /include/print/print.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | 10 | .macro Print(string) { 11 | lda #< string 12 | sta zp_tmp_lo 13 | lda #> string 14 | sta zp_tmp_hi 15 | jsr print 16 | } 17 | 18 | .macro PrintRainbow(string) { 19 | lda #< string 20 | sta zp_tmp_lo 21 | lda #> string 22 | sta zp_tmp_hi 23 | jsr print_rainbow 24 | } 25 | 26 | .macro PrintPlot(x,y) { 27 | ldx #y 28 | ldy #x 29 | clc 30 | jsr KERNAL_PLOT 31 | } 32 | 33 | .macro PrintColor(color) { 34 | lda #color 35 | sta 646 36 | } 37 | 38 | .macro PrintXY(text,x,y) { 39 | PrintPlot(x,y) 40 | Print(text) 41 | } 42 | 43 | .macro PrintXYColor(string,x,y,color) { 44 | PrintPlot(x,y) 45 | PrintColor(color) 46 | Print(string) 47 | } 48 | 49 | .macro PrintChr(char) { 50 | lda #char 51 | jsr KERNAL_CHROUT 52 | } 53 | 54 | .macro PrintStrLF(string) { 55 | Print(string) 56 | PrintChr(13) 57 | } 58 | 59 | print: 60 | clc 61 | ldy #$00 62 | !: 63 | lda (zp_tmp),y 64 | beq print_out 65 | jsr KERNAL_CHROUT 66 | inc zp_tmp_lo 67 | bne !+ 68 | inc zp_tmp_hi 69 | !: 70 | jmp !-- 71 | print_out: 72 | rts 73 | 74 | print_rainbow: 75 | clc 76 | ldy #$00 77 | pr1: 78 | lda (zp_tmp),y 79 | beq print_r_out 80 | sta print_r_t 81 | 82 | lda BACKGROUND_COLOR 83 | and #$0f 84 | cmp CURSOR_COLOR 85 | 86 | bne !+ 87 | inc CURSOR_COLOR 88 | lda CURSOR_COLOR 89 | and #15 90 | sta CURSOR_COLOR 91 | !: 92 | lda print_r_t 93 | jsr KERNAL_CHROUT 94 | 95 | inc zp_tmp_lo 96 | bne !+ 97 | inc zp_tmp_hi 98 | !: 99 | inc CURSOR_COLOR 100 | lda CURSOR_COLOR 101 | and #15 102 | sta CURSOR_COLOR 103 | jmp pr1 104 | print_r_out: 105 | rts 106 | print_r_t: 107 | .byte 0 -------------------------------------------------------------------------------- /include/print/print_ascii_to_petscii.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | #import "string/string_ascii_to_petscii.asm" 10 | 11 | 12 | .macro PrintASCII2Petscii(string) { 13 | ldx #$00 14 | !pstr: 15 | lda string,x 16 | beq !pstr+ 17 | jsr ascii_to_petscii_kp 18 | jsr KERNAL_CHROUT 19 | inx 20 | jmp !pstr- 21 | !pstr: 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /include/print/print_hex.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | 10 | ////////////////////////////////////////////////////////////////// 11 | 12 | .macro PrintHexXY(x,y) { 13 | sta a_reg 14 | ldx #y 15 | ldy #x 16 | clc 17 | jsr KERNAL_PLOT 18 | lda a_reg 19 | jsr print_hex_inline 20 | } 21 | 22 | .macro PrintHex() { 23 | jsr print_hex_inline 24 | } 25 | 26 | .macro PrintHex_Range(mem,len) { 27 | 28 | sta a_reg 29 | stx x_reg 30 | sty y_reg 31 | 32 | lda #'$' 33 | jsr KERNAL_CHROUT 34 | lda #mem 35 | PrintHex() 36 | lda #':' 37 | jsr KERNAL_CHROUT 38 | 39 | ldx #$00 40 | !: 41 | lda mem,x 42 | PrintHex() 43 | PrintChr($20) 44 | inx 45 | cpx #len 46 | bne !- 47 | 48 | lda a_reg 49 | ldx x_reg 50 | ldy y_reg 51 | 52 | } 53 | 54 | ////////////////////////////////////////////////////////////////// 55 | // print_hex ?? 56 | 57 | print_hex_inline_d: 58 | .byte 1 59 | print_hex_inline: 60 | sta zp_tmp 61 | 62 | lda print_hex_inline_d 63 | beq !+ 64 | // lda #'$' 65 | // jsr KERNAL_CHROUT 66 | !: 67 | 68 | 69 | lda zp_tmp 70 | lsr 71 | lsr 72 | lsr 73 | lsr 74 | tax 75 | lda print_hex_inline_conversion_table,x 76 | jsr KERNAL_CHROUT 77 | lda zp_tmp 78 | and #$0f 79 | tax 80 | lda print_hex_inline_conversion_table,x 81 | inc zp_ptr_screen_lo 82 | jsr KERNAL_CHROUT 83 | rts 84 | print_hex_inline_conversion_table: 85 | .byte $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$41,$42,$43,$44,$45,$46 86 | 87 | 88 | 89 | print_hex: // method 2 from kevin 90 | pha 91 | lsr 92 | lsr 93 | lsr 94 | lsr 95 | jsr print_h_digit 96 | pla 97 | and #$0f 98 | jsr print_h_digit 99 | rts 100 | 101 | print_h_digit: 102 | cmp #10 103 | bcc !+ 104 | adc #6 105 | !: 106 | adc #48 107 | jsr KERNAL_CHROUT 108 | rts 109 | 110 | 111 | /* 112 | ////////////////////////////////////////////////////////////////// 113 | // print_hex 114 | ////////////////////////////////////////////////////////////////// 115 | // POKE 2 character HEX representation of 116 | // a byte onto the screen at x,y location 117 | ////////////////////////////////////////////////////////////////// 118 | // usage: 119 | // 120 | // ldx #$05 121 | // ldy #$06 122 | // lda #$15 123 | // jsr print_hex 124 | // 125 | ////////////////////////////////////////////////////////////////// 126 | 127 | print_hex_color: .byte 2 128 | print_hex: 129 | sta zp_tmp 130 | jsr calculate_screen_pos 131 | lda zp_tmp 132 | print_hex_no_calc: 133 | sta zp_tmp 134 | lsr 135 | lsr 136 | lsr 137 | lsr 138 | tax 139 | lda print_hex_screencode_conversion_table,x 140 | ldx #$00 141 | sta (zp_ptr_screen,x) 142 | lda print_hex_color 143 | sta (zp_ptr_color,x) 144 | lda zp_tmp 145 | and #$0f 146 | tax 147 | lda print_hex_screencode_conversion_table,x 148 | inc zp_ptr_screen_lo 149 | ldx #$00 150 | sta (zp_ptr_screen,x) 151 | inc zp_ptr_color_lo 152 | lda print_hex_color 153 | sta (zp_ptr_color,x) 154 | rts 155 | 156 | print_hex_screencode_conversion_table: 157 | .byte $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$01,$02,$03,$04,$05,$06 158 | */ 159 | /* 160 | .macro PrintHex(xpos,ypos) { 161 | 162 | sta a_reg 163 | stx x_reg 164 | sty y_reg 165 | 166 | lda a_reg 167 | ldx #xpos 168 | ldy #ypos 169 | jsr print_hex 170 | 171 | ldx x_reg 172 | ldy y_reg 173 | } 174 | 175 | .macro PrintHexC(xpos,ypos,color) { 176 | sta a_reg 177 | stx x_reg 178 | sty y_reg 179 | 180 | lda #color 181 | sta print_hex_color 182 | 183 | lda a_reg 184 | ldx #xpos 185 | ldy #ypos 186 | jsr print_hex 187 | 188 | ldx x_reg 189 | ldy y_reg 190 | } 191 | */ -------------------------------------------------------------------------------- /include/print/print_leading_zeros_as_spaces.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | 10 | .macro PrintLeadingZerosAsSpaces(text) { 11 | lda #< text 12 | sta zp_tmp_lo 13 | lda #> text 14 | sta zp_tmp_hi 15 | jsr print_leading_zeros_as_spaces 16 | } 17 | 18 | ////////////////////////////////////////////////////////////////// 19 | // print leading zero pads as spaces 20 | 21 | print_leading_zeros_as_spaces: 22 | 23 | clc 24 | 25 | lda #$00 26 | sta zpnzp_c 27 | 28 | nzsp1: 29 | !wl: 30 | ldy #$00 31 | lda (zp_tmp),y 32 | bne !wl+ 33 | lda zpnzp_c 34 | bne !+ 35 | lda #$30 36 | jsr $ffd2 37 | !: 38 | rts 39 | !wl: 40 | tax 41 | cpx #$30 42 | bne wlsz 43 | 44 | iny 45 | clc 46 | lda (zp_tmp),y 47 | beq wlsz 48 | 49 | lda zpnzp_c 50 | bne wlsz 51 | lda #$20 52 | jsr $ffd2 53 | jmp wlysz 54 | 55 | wlsz: 56 | txa 57 | jsr $ffd2 58 | inc zpnzp_c 59 | wlysz: 60 | inc zp_tmp_lo 61 | bne !+ 62 | inc zp_tmp_hi 63 | !: 64 | jmp nzsp1 65 | 66 | 67 | zpnzp_c: .byte 0 -------------------------------------------------------------------------------- /include/print/print_no_leading_zeros.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | 10 | .macro PrintNoLeadingZeros(text) { 11 | lda #< text 12 | sta zp_tmp_lo 13 | lda #> text 14 | sta zp_tmp_hi 15 | jsr print_no_leading_zeros 16 | } 17 | 18 | ////////////////////////////////////////////////////////////////// 19 | // print without leading zero pad 20 | 21 | print_no_leading_zeros: 22 | 23 | clc 24 | 25 | lda #$00 26 | sta zpnzp_c 27 | 28 | nzp1: 29 | !wl: 30 | ldy #$00 31 | lda (zp_tmp),y 32 | bne !wl+ 33 | lda zpnzp_c 34 | bne !+ 35 | lda #$30 36 | jsr $ffd2 37 | !: 38 | rts 39 | !wl: 40 | tax 41 | cpx #$30 42 | bne wlz 43 | 44 | iny 45 | clc 46 | lda (zp_tmp),y 47 | beq wlz 48 | 49 | lda zpnzp_c 50 | bne wlz 51 | jmp wlyz 52 | 53 | wlz: 54 | txa 55 | jsr $ffd2 56 | inc zpnzp_c 57 | wlyz: 58 | inc zp_tmp_lo 59 | bne !+ 60 | inc zp_tmp_hi 61 | !: 62 | jmp nzp1 63 | -------------------------------------------------------------------------------- /include/print/print_screencode_to_petscii.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | #import "string/string_screencode_to_petscii.asm" 10 | 11 | .macro PrintScreenCode2Petscii(string) { 12 | ldx #$00 13 | !pstr: 14 | lda string,x 15 | beq !pstr+ 16 | jsr screencode_to_petscii 17 | jsr KERNAL_CHROUT 18 | inx 19 | jmp !pstr- 20 | !pstr: 21 | } 22 | 23 | .macro PrintScreenCode2PetsciiXY(string,x,y) { 24 | ldx #y 25 | ldy #x 26 | clc 27 | jsr KERNAL_PLOT 28 | PrintScreenCode2Petscii(string) 29 | } 30 | 31 | -------------------------------------------------------------------------------- /include/print/u_calculate_color_pos.asm: -------------------------------------------------------------------------------- 1 | 2 | ////////////////////////////////////////////////////////////////// 3 | // CITYXEN COMMODORE 64 LIBRARY 4 | // 5 | // https://github.com/cityxen/Commodore64_Programming 6 | // 7 | // https://linktr.ee/cityxen 8 | // 9 | ////////////////////////////////////////////////////////////////// 10 | // calculate_color_pos 11 | ////////////////////////////////////////////////////////////////// 12 | // Calculate color position based on x and y registers 13 | ////////////////////////////////////////////////////////////////// 14 | // Usage: 15 | // 16 | // ldx #$05 17 | // ldy #$10 18 | // jsr calculate_color_pos 19 | // 20 | ////////////////////////////////////////////////////////////////// 21 | // Result: Stores color location in zp_ptr_color 22 | ////////////////////////////////////////////////////////////////// 23 | 24 | calculate_color_pos: // x = xpos y = ypos 25 | lda #COLOR_RAM 28 | sta zp_ptr_color_hi 29 | cpx #$00 // add x pos to color pos 30 | !ccp_lp: 31 | beq !ccp_lp+ 32 | inc zp_ptr_color_lo 33 | bne !ccp_lp_i+ 34 | inc zp_ptr_color_hi 35 | !ccp_lp_i: 36 | dex 37 | jmp !ccp_lp- 38 | !ccp_lp: 39 | cpy #$00 // add y pos to color pos 40 | !ccp_lp: 41 | beq !ccp_lp+ 42 | lda zp_ptr_color_lo 43 | clc 44 | adc #$28 45 | sta zp_ptr_color_lo 46 | bcc !ccp_lp_i+ 47 | inc zp_ptr_color_hi 48 | !ccp_lp_i: 49 | dey 50 | jmp !ccp_lp- 51 | !ccp_lp: 52 | rts 53 | 54 | increment_color_pos: 55 | inc zp_ptr_color_lo 56 | bne !icp_exit+ 57 | inc zp_ptr_color_hi 58 | !icp_exit: 59 | rts 60 | 61 | addto_color_pos: 62 | lda zp_ptr_color_lo 63 | clc 64 | adc #$28 65 | sta zp_ptr_color_lo 66 | bcc !acp_exit+ 67 | inc zp_ptr_color_hi 68 | !acp_exit: 69 | rts -------------------------------------------------------------------------------- /include/print/u_calculate_screen_pos.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | ////////////////////////////////////////////////////////////////// 9 | // calculate_screen_pos 10 | ////////////////////////////////////////////////////////////////// 11 | // Calculate screen position based on x and y registers 12 | ////////////////////////////////////////////////////////////////// 13 | // Usage: 14 | // 15 | // ldx #$05 16 | // ldy #$10 17 | // jsr calculate_screen_pos 18 | // 19 | ////////////////////////////////////////////////////////////////// 20 | // Result: Stores screen location in zp_ptr_screen 21 | ////////////////////////////////////////////////////////////////// 22 | 23 | calculate_screen_pos: // x = xpos y = ypos 24 | lda #SCREEN_RAM 27 | sta zp_ptr_screen_hi 28 | lda #COLOR_RAM 31 | sta zp_ptr_color_hi 32 | 33 | cpx #$00 // add x pos to screen pos 34 | !csp_lp: 35 | beq !csp_lp+ 36 | inc zp_ptr_screen_lo 37 | inc zp_ptr_color_lo 38 | bne !csp_lp_i+ 39 | inc zp_ptr_screen_hi 40 | inc zp_ptr_color_hi 41 | !csp_lp_i: 42 | dex 43 | jmp !csp_lp- 44 | !csp_lp: 45 | cpy #$00 // add y pos to screen pos 46 | !csp_lp: 47 | beq !csp_lp+ 48 | lda zp_ptr_color_lo 49 | clc 50 | adc #$28 51 | sta zp_ptr_color_lo 52 | lda zp_ptr_screen_lo 53 | clc 54 | adc #$28 55 | sta zp_ptr_screen_lo 56 | bcc !csp_lp_i+ 57 | inc zp_ptr_screen_hi 58 | inc zp_ptr_color_hi 59 | !csp_lp_i: 60 | dey 61 | jmp !csp_lp- 62 | !csp_lp: 63 | rts 64 | 65 | increment_screen_pos: 66 | inc zp_ptr_screen_lo 67 | bne !isp_exit+ 68 | inc zp_ptr_screen_hi 69 | !isp_exit: 70 | rts 71 | 72 | addto_screen_pos: 73 | lda zp_ptr_screen_lo 74 | clc 75 | adc #$28 76 | sta zp_ptr_screen_lo 77 | bcc !asp_exit+ 78 | inc zp_ptr_screen_hi 79 | !asp_exit: 80 | rts -------------------------------------------------------------------------------- /include/random.il.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | ////////////////////////////////////////////////////////////// 10 | // Random number stuff 11 | 12 | random_num: .byte 0 13 | 14 | random_init_sid: 15 | // Set up sid to produce random values 16 | lda #$FF // maximum frequency value 17 | sta $D40E // voice 3 frequency low byte 18 | sta $D40F // voice 3 frequency high byte 19 | lda #$80 // noise waveform, gate bit off 20 | sta $D412 // voice 3 control register 21 | rts 22 | 23 | lda_random_sid: 24 | lda $d41b // lda with random number 25 | sta random_num 26 | rts 27 | 28 | lda_random_kern: 29 | jsr $E097 30 | lda $8f 31 | sta random_num 32 | rts 33 | -------------------------------------------------------------------------------- /include/rle.il.asm: -------------------------------------------------------------------------------- 1 | #importonce 2 | 3 | .const zp_src = $f7 4 | .const zp_rle_start = $f9 5 | .const zp_dest = $fb 6 | .const zp_rle_end = $fd 7 | 8 | rle_data_size: 9 | rle_data_size_lo: 10 | .byte $00 11 | rle_data_size_hi: 12 | .byte $00 13 | 14 | rle_count: 15 | .byte $00 16 | 17 | rle_byte: 18 | .byte $00 19 | 20 | rle_data: 21 | .byte $00 22 | .byte $30 23 | 24 | rle_set_dest: 25 | stx zp_dest 26 | sty zp_dest+1 27 | rts 28 | 29 | rle_set_src: 30 | stx zp_src 31 | sty zp_src+1 32 | rts 33 | 34 | inc_rle_data_size: 35 | clc 36 | inc rle_data_size_lo 37 | bcc !+ 38 | inc rle_data_size_hi 39 | !: 40 | rts 41 | 42 | rle_compress: 43 | 44 | lda zp_dest 45 | sta zp_rle_start 46 | lda zp_dest+1 47 | sta zp_rle_start+1 48 | 49 | lda #$00 50 | sta rle_data_size_lo 51 | sta rle_data_size_hi 52 | 53 | ldy #$00 54 | lda (zp_src),y 55 | sta rle_byte 56 | inc rle_count 57 | inc zp_src 58 | 59 | gr_loop: 60 | lda (zp_src),y 61 | cmp rle_byte 62 | bne gr_diff 63 | 64 | gr_same: 65 | lda rle_count 66 | cmp #255 67 | bne gr_next 68 | 69 | gr_diff: 70 | lda rle_count 71 | sta (zp_dest),y 72 | jsr inc_rle_data_size 73 | lda rle_byte 74 | iny 75 | sta (zp_dest),y 76 | jsr inc_rle_data_size 77 | dey 78 | lda (zp_src),y 79 | sta rle_byte 80 | lda #0 81 | sta rle_count 82 | clc 83 | lda zp_dest 84 | adc #2 85 | sta zp_dest 86 | bcc gr_next 87 | inc zp_dest+1 88 | 89 | gr_next: 90 | inc rle_count 91 | inc zp_src 92 | bne !+ 93 | inc zp_src+1 94 | !: 95 | lda zp_src+1 96 | cmp file_size+1 97 | bcc gr_loop 98 | lda zp_src 99 | cmp file_size 100 | bcc gr_loop 101 | 102 | lda rle_count 103 | beq !+ 104 | sta (zp_dest),y 105 | jsr inc_rle_data_size 106 | iny 107 | lda rle_byte 108 | sta (zp_dest),y 109 | jsr inc_rle_data_size 110 | iny 111 | lda #0 112 | sta (zp_dest),y 113 | jsr inc_rle_data_size 114 | iny 115 | sta (zp_dest),y 116 | jsr inc_rle_data_size 117 | !: 118 | 119 | lda rle_data_size 120 | clc 121 | adc zp_rle_start 122 | sta zp_rle_end 123 | 124 | lda zp_dest 125 | sta zp_rle_end 126 | 127 | lda rle_data_size+1 128 | adc zp_rle_start+1 129 | sta zp_rle_end+1 130 | 131 | lda zp_dest+1 132 | sta zp_rle_end+1 133 | 134 | rts 135 | 136 | 137 | 138 | 139 | 140 | rle_decompress: //; decompress rle-encoded screen data 141 | 142 | 143 | rd1: 144 | ldy #0 145 | lda (zp_src),y 146 | beq rd2 147 | tax 148 | pha 149 | iny 150 | lda (zp_src),y 151 | dey 152 | !: 153 | sta (zp_dest),y 154 | iny 155 | dex 156 | bne !- 157 | pla 158 | clc 159 | adc zp_dest 160 | sta zp_dest 161 | bcc !+ 162 | inc zp_dest+1 163 | !: 164 | lda zp_src 165 | clc 166 | adc #2 167 | sta zp_src 168 | bcc !+ 169 | inc zp_src+1 170 | !: 171 | jmp rd1 172 | rd2: 173 | rts 174 | 175 | 176 | .macro RLE_SetSrc(num) { 177 | lda #num 180 | sta zp_src+1 181 | } 182 | 183 | .macro RLE_SetDest(num) { 184 | lda num 185 | sta zp_dest 186 | lda num+1 187 | sta zp_dest+1 188 | } -------------------------------------------------------------------------------- /include/score.il.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | 10 | score: // Bytes of the score in BCD 11 | // LSB --------------- MSB 12 | .byte $00,$00,$00,$00,$00 13 | 14 | score_str: .text "0000000000" // String of the score 15 | .byte 0 16 | score_digits: .byte $09 // num of digits to display (default is 10) 17 | score_math_o: .byte $00 // Math Val 18 | 19 | 20 | .macro DrawScore(x,y) { 21 | clc // Set cursor position 22 | ldy #x // X coordinate (column) 23 | ldx #y // Y coordinate (line) 24 | jsr $fff0 25 | PrintNoLeadingZeros(score_str) 26 | } 27 | 28 | //////////////////////////////////////////////// 29 | // Update string from score 30 | 31 | score_to_str: 32 | 33 | ldx #$00 34 | ldy score_digits 35 | !: 36 | lda score,x 37 | pha 38 | and #$0f 39 | clc 40 | adc #48 41 | sta score_str,y 42 | dey 43 | pla 44 | lsr 45 | lsr 46 | lsr 47 | lsr 48 | clc 49 | adc #48 50 | sta score_str,y 51 | dey 52 | 53 | inx 54 | cpx #5 55 | bne !- 56 | 57 | rts 58 | 59 | 60 | //////////////////////////////////////////////// 61 | // Update score from string 62 | 63 | score_from_str: 64 | 65 | ldx #$00 66 | ldy #$04 67 | !: 68 | lda score_str,x 69 | 70 | and #$0f 71 | 72 | clc 73 | asl 74 | asl 75 | asl 76 | asl 77 | 78 | sta score,y 79 | 80 | inx 81 | lda score_str,x 82 | and #$0f 83 | ora score,y 84 | sta score,y 85 | 86 | inx 87 | dey 88 | cpy #$ff 89 | bne !- 90 | 91 | rts 92 | 93 | 94 | //////////////////////////////////////////////// 95 | // Reset score to 0 96 | 97 | score_reset: 98 | 99 | lda #$00 100 | 101 | sta score 102 | sta score+1 103 | sta score+2 104 | sta score+3 105 | sta score+4 106 | 107 | jsr score_to_str 108 | 109 | rts 110 | 111 | //////////////////////////////////////////////// 112 | // Add score_math_o to score 113 | 114 | score_add: 115 | 116 | sed 117 | 118 | clc 119 | lda score 120 | adc score_math_o 121 | sta score 122 | lda score+1 123 | adc #0 124 | sta score+1 125 | lda score+2 126 | adc #0 127 | sta score+2 128 | lda score+3 129 | adc #0 130 | sta score+3 131 | lda score+4 132 | adc #0 133 | sta score+4 134 | 135 | cld 136 | 137 | jsr score_to_str 138 | 139 | rts 140 | 141 | //////////////////////////////////////////////// 142 | // Subtract score_math_o from score 143 | 144 | score_sub: 145 | 146 | sed 147 | 148 | sec 149 | lda score 150 | sbc score_math_o 151 | sta score 152 | lda score+1 153 | sbc #0 154 | sta score+1 155 | lda score+2 156 | sbc #0 157 | sta score+2 158 | lda score+3 159 | sbc #0 160 | sta score+3 161 | lda score+4 162 | sbc #0 163 | sta score+4 164 | 165 | cld 166 | 167 | bcs !+ // can't be less than 0 168 | jsr score_reset 169 | !: 170 | 171 | jsr score_to_str 172 | 173 | rts 174 | 175 | 176 | is_score_zero: 177 | lda #$00 178 | sta score_zero 179 | sed 180 | clc 181 | lda score 182 | beq !+ 183 | inc score_zero 184 | !: 185 | lda score+1 186 | beq !+ 187 | inc score_zero 188 | !: 189 | lda score+2 190 | beq !+ 191 | inc score_zero 192 | !: 193 | lda score+3 194 | beq !+ 195 | inc score_zero 196 | !: 197 | lda score+4 198 | beq !+ 199 | inc score_zero 200 | !: 201 | cld 202 | lda score_zero 203 | rts 204 | score_zero: 205 | .byte 0 206 | -------------------------------------------------------------------------------- /include/sfxkit.il.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | ////////////////////////////////////////////////////////////////// 10 | // SOUND FX KIT STUFF 11 | 12 | #define CONFIG_SFXKIT 13 | 14 | .macro FixSFXKit(loc) { 15 | lda #$3a 16 | sta loc+$0128 17 | sta loc+$0129 18 | sta loc+$012a 19 | } 20 | 21 | .const SFK_VOICE_1 = $02a7 22 | .const SFK_VOICE_2 = $02a8 23 | .const SFK_VOICE_3 = $02a9 24 | 25 | .macro sfx_v1_play(sfx) { 26 | lda #sfx 27 | sta SFK_VOICE_1 28 | } 29 | 30 | .macro sfx_v2_play(sfx) { 31 | lda #sfx 32 | sta SFK_VOICE_2 33 | } 34 | 35 | .macro sfx_v3_play(sfx) { 36 | lda #sfx 37 | sta SFK_VOICE_3 38 | } 39 | 40 | sfx_sound_on: 41 | jsr $c000 42 | rts 43 | 44 | sfx_sound_off: 45 | jsr $c010 46 | rts 47 | 48 | sfx_clear: 49 | jsr $c1f9 50 | rts 51 | -------------------------------------------------------------------------------- /include/string.il.asm: -------------------------------------------------------------------------------- 1 | #import "string/strcpy.asm" 2 | #import "string/strlen.asm" 3 | #import "string/string_buffer.asm" 4 | #import "string/string_ascii_to_petscii.asm" 5 | #import "string/string_screencode_to_petscii.asm" 6 | #import "string/strings.asm" 7 | #import "string/string_hex_to_val.asm" -------------------------------------------------------------------------------- /include/string/strcpy.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | 10 | .macro StrCpyL(str_from,str_to,len) { 11 | ldx #$00 12 | !: 13 | lda str_from,x 14 | sta str_to,x 15 | inx 16 | cpx #len 17 | bne !- 18 | } 19 | 20 | .macro StrCpy(str_from,str_to) { 21 | lda #< str_from 22 | sta zp_tmp_lo 23 | lda #> str_from 24 | sta zp_tmp_hi 25 | 26 | lda #< str_to 27 | sta zp_tmp2_lo 28 | lda #> str_to 29 | sta zp_tmp2_hi 30 | 31 | jsr string_copy 32 | } 33 | 34 | string_copy: 35 | clc 36 | ldy #$00 37 | string_copy_1: 38 | lda (zp_tmp),y 39 | sta (zp_tmp2),y 40 | beq string_copy_2 41 | inc zp_tmp_lo 42 | bne !+ 43 | inc zp_tmp_hi 44 | !: 45 | inc zp_tmp2_lo 46 | bne !+ 47 | inc zp_tmp2_hi 48 | !: 49 | jmp string_copy_1 50 | string_copy_2: 51 | rts -------------------------------------------------------------------------------- /include/string/string_ascii_to_petscii.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | 10 | ////////////////////////////////////////////////////////////////// 11 | 12 | /* 13 | .macro ConvertA2P(string,len) { 14 | ldx #$00 15 | !: 16 | lda string,x 17 | beq !+ 18 | jsr screencode_to_petscii // ascii_to_petscii_kp 19 | sta string,x 20 | inc string,x 21 | inx 22 | cpx #len 23 | bne !- 24 | !: 25 | } 26 | */ 27 | 28 | ////////////////////////////////////////////////////////////////// 29 | // convert ascii to petscii (from idolpx) 30 | 31 | ascii_to_petscii: 32 | cmp #$41 // Compare with 'A' 33 | bcc !+ // If less, return 34 | cmp #$7F // Compare with 'DEL' 35 | bcs !+ // If greater or equal, return 36 | sbc #$5F // Convert 'A-Z' & 'a-z' to PETSCII 37 | !: 38 | rts // Return from subroutine 39 | 40 | ascii_to_petscii_kp: // (kernel print) 41 | cmp #$41 // Compare with 'A' 42 | bcc !+ // If less, return 43 | cmp #$7F // Compare with 'DEL' 44 | bcs !+ // If greater or equal, return 45 | sbc #$1f // Convert 'A-Z' & 'a-z' to PETSCII 46 | !: 47 | rts // Return from subroutine 48 | -------------------------------------------------------------------------------- /include/string/string_buffer.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | 10 | ////////////////////////////////////////////////////////////////// 11 | // reusable string buffer data 12 | strbuf: 13 | .fill 256,0 14 | buf_crsr: 15 | .byte 0 16 | 17 | ////////////////////////////////////////////////////////////////// 18 | // zero string buffer 19 | 20 | zero_strbuf: 21 | lda #$00 22 | ldx #$00 23 | !: 24 | sta strbuf,x 25 | inx 26 | bne !- 27 | stx buf_crsr 28 | rts 29 | -------------------------------------------------------------------------------- /include/string/string_hex_to_val.asm: -------------------------------------------------------------------------------- 1 | 2 | string_hex: 3 | .text "c000" 4 | .byte 0 5 | hex_val: 6 | .byte 0 7 | .byte 0 8 | hex_tmp: 9 | .byte 0 10 | int_acc: 11 | .byte 0 12 | 13 | hexstr16_to_val: 14 | 15 | lda #$00 16 | sta hex_tmp 17 | sta int_acc 18 | sta hex_val 19 | sta hex_val+1 20 | 21 | tax 22 | lda string_hex,x 23 | jsr screencode_to_petscii 24 | jsr hex_cvrt 25 | 26 | inx 27 | lda string_hex,x 28 | jsr screencode_to_petscii 29 | jsr hex_cvrt 30 | 31 | lda int_acc 32 | sta hex_val+1 33 | 34 | lda #$00 35 | sta hex_tmp 36 | sta int_acc 37 | 38 | inx 39 | lda string_hex,x 40 | jsr screencode_to_petscii 41 | jsr hex_cvrt 42 | 43 | 44 | inx 45 | lda string_hex,x 46 | jsr screencode_to_petscii 47 | jsr hex_cvrt 48 | 49 | lda int_acc 50 | sta hex_val 51 | 52 | rts 53 | 54 | hex_cvrt: 55 | stx x_reg 56 | 57 | cmp #$30 58 | bcc h2vend 59 | cmp #$39 60 | bcs is_hex 61 | sec 62 | sbc #$30 63 | jmp add_value 64 | 65 | is_hex: 66 | cmp #$41 67 | bcc h2vend 68 | cmp #$47 69 | bcs h2vend 70 | sec 71 | sbc #55 72 | 73 | add_value: 74 | sta hex_tmp 75 | lda int_acc 76 | asl // multiply by 16 (shift left 4 times) 77 | asl 78 | asl 79 | asl 80 | clc 81 | adc hex_tmp // add the digit value 82 | sta int_acc 83 | 84 | h2vend: 85 | ldx x_reg 86 | rts 87 | 88 | 89 | -------------------------------------------------------------------------------- /include/string/string_screencode_to_petscii.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | #importonce 9 | 10 | 11 | .macro StrScreenCodeToPetscii(string,len) { 12 | ldx #$00 13 | !: 14 | lda string,x 15 | jsr screencode_to_petscii 16 | sta string,x 17 | inx 18 | cpx #len 19 | bne !- 20 | } 21 | 22 | ////////////////////////////////////////////////////////////////// 23 | // convert screencode to petscii 24 | 25 | screencode_to_petscii: 26 | beq !+ 27 | cmp #32 28 | bcc sc2p_add64 29 | cmp #64 30 | bcc sc2p_add0 31 | cmp #96 32 | bcc sc2p_add128 33 | cmp #128 34 | bcc sc2p_add64 35 | cmp #160 36 | bcc sc2p_sub128 37 | cmp #224 38 | bcc sc2p_sub64 39 | cmp #254 40 | bcc sc2p_add0 41 | !: 42 | rts 43 | 44 | sc2p_sub128: 45 | sec 46 | sbc #64 47 | sc2p_sub64: 48 | sec 49 | sbc #64 50 | rts 51 | sc2p_add128: 52 | clc 53 | adc #64 54 | sc2p_add64: 55 | clc 56 | adc #64 57 | sc2p_add0: 58 | rts 59 | -------------------------------------------------------------------------------- /include/string/strings.asm: -------------------------------------------------------------------------------- 1 | STR_PRESSKEY: 2 | .encoding "screencode_mixed" 3 | .byte $0d 4 | .text "PRESS ANY KEY" 5 | .byte 0 6 | 7 | -------------------------------------------------------------------------------- /include/string/strlen.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | str_len: 4 | .byte 0 5 | 6 | .macro StrLen(instring) { 7 | ldx #$ff 8 | stx str_len 9 | !: 10 | inx 11 | lda instring,x 12 | bne !- 13 | stx str_len 14 | } 15 | -------------------------------------------------------------------------------- /include/sys.il.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | a_reg: .byte 0 10 | x_reg: .byte 0 11 | y_reg: .byte 0 12 | tmp_1: .byte 0 13 | tmp_2: .byte 0 14 | tmp_3: .byte 0 15 | 16 | /////////////// 17 | // Wait VBL 18 | 19 | wait_vbl: 20 | lda $D011 21 | and #$80 22 | bne wait_vbl 23 | rts 24 | 25 | // bit $d011 26 | // bpl wait_vbl 27 | // lda $d012 28 | // f: cmp $d012 29 | // bmi f 30 | // rts 31 | -------------------------------------------------------------------------------- /include/timers.il.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | 9 | .macro InitTimersDefault() { 10 | lda #60 // 1 sec 11 | sta irq_timer1_to 12 | lda #120 // 2 sec 13 | sta irq_timer2_to 14 | lda #180 // 3 sec 15 | sta irq_timer3_to 16 | lda #240 // 4 sec 17 | sta irq_timer4_to 18 | lda #300 // 5 sec 19 | sta irq_timer5_to 20 | jsr init_timers 21 | } 22 | .macro InitTimers(t1,t2,t3,t4,t5) { 23 | lda #t1 24 | sta irq_timer1_to 25 | lda #t2 26 | sta irq_timer2_to 27 | lda #t3 28 | sta irq_timer3_to 29 | lda #t4 30 | sta irq_timer4_to 31 | lda #t5 32 | sta irq_timer5_to 33 | jsr init_timers 34 | } 35 | 36 | //////////////////////////////// 37 | irq_timer1: .byte 0 // timers 38 | irq_timer2: .byte 0 39 | irq_timer3: .byte 0 40 | irq_timer4: .byte 0 41 | irq_timer5: .byte 0 42 | irq_timer_input: .byte 0 43 | irq_timer_jitter: .byte 0 44 | irq_timer_sound: .byte 0 45 | irq_timer_joystick: .byte 0 46 | //////////////////////////////// 47 | irq_timer1_to: .byte 0 // timeouts 48 | irq_timer2_to: .byte 0 49 | irq_timer3_to: .byte 0 50 | irq_timer4_to: .byte 0 51 | irq_timer5_to: .byte 0 52 | irq_timer_input_to: .byte 0 53 | irq_timer_jitter_to: .byte 0 54 | irq_timer_sound_to: .byte 0 55 | irq_timer_joystick_to:.byte 0 56 | //////////////////////////////// 57 | irq_timer1_tr: .byte 0 // triggers 58 | irq_timer2_tr: .byte 0 59 | irq_timer3_tr: .byte 0 60 | irq_timer4_tr: .byte 0 61 | irq_timer5_tr: .byte 0 62 | irq_timer_input_tr: .byte 0 63 | irq_timer_jitter_tr: .byte 0 64 | irq_timer_sound_tr: .byte 0 65 | irq_timer_joystick_tr:.byte 0 66 | 67 | init_timers: 68 | sei 69 | lda #irq_timers 72 | sta $0315 73 | cli 74 | rts 75 | 76 | 77 | irq_timers: 78 | 79 | #if CONFIG_MUSIC 80 | lda play_music 81 | beq !it+ 82 | jsr music.play 83 | jmp !it++ 84 | #endif 85 | !it: 86 | 87 | #if CONFIG_SFXKIT 88 | jsr $c028 // sound fx kit 89 | #endif 90 | !it: 91 | 92 | inc irq_timer1 93 | inc irq_timer2 94 | inc irq_timer3 95 | inc irq_timer4 96 | inc irq_timer5 97 | inc irq_timer_input 98 | inc irq_timer_jitter 99 | inc irq_timer_joystick 100 | inc irq_timer_sound 101 | 102 | lda irq_timer1 103 | cmp irq_timer1_to 104 | bne !+ 105 | inc irq_timer1_tr 106 | lda #$00 107 | sta irq_timer1 108 | 109 | !: 110 | lda irq_timer2 111 | cmp irq_timer2_to 112 | bne !+ 113 | inc irq_timer2_tr 114 | lda #$00 115 | sta irq_timer2 116 | 117 | !: 118 | lda irq_timer3 119 | cmp irq_timer3_to 120 | bne !+ 121 | inc irq_timer3_tr 122 | lda #$00 123 | sta irq_timer3 124 | 125 | !: 126 | lda irq_timer4 127 | cmp irq_timer4_to 128 | bne !+ 129 | inc irq_timer4_tr 130 | lda #$00 131 | sta irq_timer4 132 | 133 | !: 134 | lda irq_timer5 135 | cmp irq_timer5_to 136 | bne !+ 137 | inc irq_timer5_tr 138 | lda #$00 139 | sta irq_timer5 140 | !: 141 | 142 | lda irq_timer_sound 143 | cmp irq_timer_sound_to 144 | bne !+ 145 | inc irq_timer_sound_tr 146 | lda #$00 147 | sta irq_timer_sound 148 | 149 | !: 150 | 151 | lda irq_timer_joystick 152 | cmp irq_timer_joystick_to 153 | bne !+ 154 | inc irq_timer_joystick_tr 155 | lda #$00 156 | sta irq_timer_joystick 157 | 158 | !: 159 | 160 | lda irq_timer_jitter 161 | cmp irq_timer_jitter_to 162 | bne !+ 163 | inc irq_timer_jitter_tr 164 | lda #$00 165 | sta irq_timer_jitter 166 | 167 | !: 168 | 169 | lda irq_timer_input 170 | cmp irq_timer_input_to 171 | bne !+ 172 | inc irq_timer_input_tr 173 | lda #$00 174 | sta irq_timer_input 175 | 176 | !: 177 | 178 | jmp $ea31 179 | 180 | 181 | pause1: 182 | jsr reset_timer1 183 | !: 184 | lda irq_timer1_tr 185 | beq !- 186 | jsr reset_timer1 187 | rts 188 | 189 | pause2: 190 | jsr reset_timer2 191 | !: 192 | lda irq_timer2_tr 193 | beq !- 194 | jsr reset_timer2 195 | rts 196 | 197 | pause3: 198 | jsr reset_timer3 199 | !: 200 | lda irq_timer3_tr 201 | beq !- 202 | jsr reset_timer3 203 | rts 204 | 205 | pause4: 206 | jsr reset_timer4 207 | !: 208 | lda irq_timer4_tr 209 | beq !- 210 | jsr reset_timer4 211 | rts 212 | 213 | pause5: 214 | jsr reset_timer5 215 | !: 216 | lda irq_timer5_tr 217 | beq !- 218 | jsr reset_timer5 219 | rts 220 | 221 | 222 | reset_timer1: 223 | lda #$00 224 | sta irq_timer1 225 | sta irq_timer1_tr 226 | rts 227 | 228 | reset_timer2: 229 | lda #$00 230 | sta irq_timer2 231 | sta irq_timer2_tr 232 | rts 233 | 234 | reset_timer3: 235 | lda #$00 236 | sta irq_timer3 237 | sta irq_timer3_tr 238 | rts 239 | 240 | reset_timer4: 241 | lda #$00 242 | sta irq_timer4 243 | sta irq_timer4_tr 244 | rts 245 | 246 | reset_timer5: 247 | lda #$00 248 | sta irq_timer5 249 | sta irq_timer5_tr 250 | rts 251 | 252 | reset_input_timer: 253 | lda #$00 254 | sta irq_timer_input 255 | sta irq_timer_input_tr 256 | sta $C6 // clear buffer 257 | jsr KERNAL_GETIN 258 | rts 259 | 260 | reset_jitter_timer: 261 | lda #$00 262 | sta irq_timer_jitter_tr 263 | sta irq_timer_jitter 264 | rts 265 | 266 | reset_sound_timer: 267 | lda #$00 268 | sta irq_timer_sound_tr 269 | sta irq_timer_sound 270 | rts 271 | 272 | reset_joystick_timer: 273 | lda #$00 274 | sta irq_timer_joystick_tr 275 | sta irq_timer_joystick 276 | rts 277 | -------------------------------------------------------------------------------- /include/userport.il.asm: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////// 2 | // CITYXEN COMMODORE 64 LIBRARY 3 | // 4 | // https://github.com/cityxen/Commodore64_Programming 5 | // 6 | // https://linktr.ee/cityxen 7 | // 8 | -------------------------------------------------------------------------------- /sfx/Sound_FX_Kit.d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/sfx/Sound_FX_Kit.d64 -------------------------------------------------------------------------------- /sfx/Sound_FX_Kit_Instructions (Page 35) Commodore_DiskUser_Issue_10_1989_May-Jun_text.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/sfx/Sound_FX_Kit_Instructions (Page 35) Commodore_DiskUser_Issue_10_1989_May-Jun_text.pdf -------------------------------------------------------------------------------- /storage/Compute's_Reference_Guide_to_Commodore_64_Graphics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cityxen/Commodore64_Programming/7f3734da9c047ad2aba509866725cbffc44ae43c/storage/Compute's_Reference_Guide_to_Commodore_64_Graphics.pdf --------------------------------------------------------------------------------