************************************************************ * * * Edass 128 Editor + Assembler for Commodore C128 * * last .doc modification on 09.4.2024 * * by lived.ch * * * * * ************************************************************ ************************************************************ * UPDATE INFO * *--------------------------------------------------------- * * SFK.BAS on floppy disk * * Small, compact and with just one function: * * to set the F-KEYs for Edass 128 * * >>>> SFK.BAS is now adding file name ending .ASM <<<< * *----------------------------------------------------------* * All SFK files are now highres Graphic x mode compatible! * * * * RES-SFK.BL is resetting to default C128 F-KEY settings! * * To be bload and SYS 2024 * *----------------------------------------------------------* * In case you need RAM memory from $0ac5 to $0bff * * do not use SFK1.BAS {SFK128ML.BL} to modify F-KEYs! * ************************************************************ The past days, in November 2023, I was looking for Commodore C128 assemblers. The reason was: C128 was my first computer back in the days, 1987 and something. Many decades ago, haha... Lately i was actually trying out TMP+REU 1.2 assembler and i like it because it has no lines (https://turbo.style64.org/) To find an assembler for C128 in C128 Mode wasn't so easy, but Edass 128 ASSEMBLER was a full success. Looks like an old version from 1986! Latest Edass assembler is V.1.8 from 1988 but i can't find a workable download for it. It's not TMP+REU 1.2 in terms of usability, especially moving around the editor, but it has no lines, it's for C128 and i can paste the source code of TMP to Edass! No issues with format or labels! That's all i ever wanted. Plus it has tons of functions! Running rock stable (unless you crash it with bad poking around the system!) { didn't tried Macros! } Anyway, let's go! {nooo, that's Anatoly on YouTube {some free advertising for him haha... }} We are let's go C128! ;-) *************************************************************************** * So here is a "quick" how to start with Edass 128 ASSEMBLER. * *************************************************************************** > Short info about C128 BASIC { when Edass 128 is installed }: Without usage of graphic screens you have approx. 11KB free, and with graphics only 2KB. For BASIC variables 3KB are reserved. That means: If you write BASIC-/Assembler-Combo, you better know your default limits. Or change settings if you need less assembler, more BASIC space with the !NEW command of Edass 128! Check the Edass Book for additional information. { i have only german book. if anyone is having this in english, let me know } { or if you have newer working version of Edass 128. Thanks a lot in advance } > Short info about C128 free memory for your assembly code: $0B00 - $0bff - If NO dataset is used or if... { assembly part of SFK1.BAS {SFK128ML.BL} is here from $0ac5 to $0bff } { if you need this space, try SFK.BAS. It's BASIC only, very short & funcional } { and will sure work more stable in case you'll work with high/low resolution graphics } $0c00 - Ocff - If NO RS232 Interface is used { you can go up to $fff, if you don't use SPRDEF for sprite definition's } { that is a lot of room for practicing with assembler } { SPRDEF is storing sprite definitions from $0e00 } { meaning, if you do plan using use sprites, you still have space $0c00 - 0dff } { from $1000 Function Keys are defined, so don't go there } { that's $0fff + $01 } $1300 - $19FF - Huge Space below BASIC ($1C01), a bit less than 2KB { note: between $1a00 and 1bff, Edass 128 is resident } { don't 'poke' anything at that locations !!! } { Main location of Edass is $b400 and up, Bank 1 } $1C00 - $3FFF - BASIC RAM is AVAILABLE { but as mentioned you it's only 11 KB there without graphic screens } { However, if you aren't planing BASIC-Assembler cooperation } { then there you go, 11KB free space for your assembler code } Zero Page $00 - $ff - Almost all occupied by Edass 128 { can't say what 'almost all' is, couldn't find any info } { But if only a few addresses are free, } { unused by the system, how much could 'almost all' be? } Normally available in Zero Page: dec 251-254, hex $fb-$fe dec 010-143, hex $Oa-$8f and only if BASIC is not used! And where else? If you arent going to use SPRDEF, then there is: dec 4791-4853, hex $12B7-$12F5 free ,062 And that's still not all, there is more: ,{ bytes available } dec 0673, hex $02a1 Unused,001 vector, dec 0786-0787, hex $0312-$0313 Unused,002 dec 0996-1007, hex $03e4-$03ef Unused,012 { ocupied by Edass 128 } dec 1021-1023, hex $03fd-$03ff Unused,003 dec 2024-2039, hex $07e8-$07f7 Unused,015 dec 2048-2559, hex $0800-$09FF Unused,512 { BASIC Runtime Stack (use if no BASIC is used) } dec 2622-2623, hex $Oa3e-$Oa3f Unused,002 dec 2651-2655, hex $Oa5b-$Oa5f Unused,005 dec 2670-2687, hex $Oa6e-$Oa7f Unused,018 dec 2736, hex $Oab0 Unused,001 dec 2746-2751, hex $Oaba-$Oabf Unused,006 dec 2757, hex $Oac5 Unused,001 dec 2758-2815, hex $Oac6-$Oaff Unused,058 dec 4590-4607, hex $11ee-$11ff Unused,017 dec 4862-4863, hex $12FE-$12FF Unused,001 dec 16416 - 8, hex $4020-$ 2 Unused,003 dec 49200 - 2, hex $C030-$ 2 Unused,003 IMPORTANT!!! Occupied RAM by Edass 128: $03E4 - $03EF Bank 0 $1A00 - $1BFF - $F000 - $FEFF - $B400 - $FEFF Bank 1 Occupied Vectors by Edass 128: IMAIN - $0302 CLTVEC - $0334 SHFVEC - $0336 ESCVEC - $0338 Occupied Zero-Page by Edass 128: Close to all { Book isn't saying what it is exactly! } { Conclusion is, it might be all!? } { i didn't tried anything so far } NOW LISTEN... Hahaha... [ I never told you this: Imagine using a cross assembler, which ] [ is occupying zero space of your C128... ] [ no, don't think about it, that's a romantic retro mood killer! ] *************************************************************************** * Note : {[( all in here is commenting and MUST not be typed in )]} * *************************************************************************** And back to Edass 128 Assembler! { Assuming a usage of VICE C128 Emulator! } Download Edass 128 image @ www.lived.ch, attach it and write BOOT and press ENTER on PC Keyboard (unless you are using some kind of USB-Retro Keyboard with RETURN key, or you can do Autostart. { later I'll talk about SFK.BAS. For now just know it's existing } 1. Load the program (probably done by now) 2. Type !BEGIN"(name of the programm)" e.g. !BEGIN"TEST" { you can manage up to 10 of those } { just don't put them all on the same start address } 3. Type !DISPLAY to see it (if you want) { this is also good if you can't remember the names anymore } 4. Type !EDIT"TEST" this is starting the assembly editor { no line numbers, thank you very much, SUPER NICE and COOL! } Here an example of the code: Note: { in case you noticed a typo after you entered everything } { press "SHIFT + RETURN" to additionaly edit the lines } { after the changes were done, press on RETURN to save the changes } { press on "SHIFT & RETURN" to leave the additional editing mode } { and can add new lines without overwritting existing once accidentally } { you must have space between the mnemonic and its value } { lda #$00 is OK lda#$00 is NOT okay! } Now back to business again! EXAMPLE 1: How to... *= $1300 { this is our start address } { usable until $1a00, as mentioned before } { way more than enough for our examples codes } .obj M { saving to memory } .bank 15 { where your data is saved } lda #$0b sta $d020 tax inx txa sta $d021 lda #$07 sta $f1 rts .end 5. Type !EXIT to leave the assembler editing mode { <- arrow + ENTER/RETURN would do too! this is left arrow like in TurboMacroPro assembler } { On VICE with USA English keyboard layout, i must press on SHIFT and left upper corner, } { below ESC, to activate this <- arrow } Well, I guess you probably want to see what's the result.. 6. Type !ASSEMBLER"TEST" Since I have only *German version of Edass, it's giving me the "ASSEMBLIERUNG IM GANGE" or "ASSEMBLING IS RUNNING" message. { *can't find all English working version absolutely nowhere } F0B10-ENDE DER ASSEMBLIERUNG ! READY. So, that is done and you are ready to go and start your program. To do that you can type: !GO$1300 { the start address of your program } It's not doing much, but it is something. In case you have a desire to rename your program, it can be done like this: 7. Type !RENAME"TEST"="COLOR" You probably also want to save at some point. Yes, you think correct. 8. Type !SAVE"COLOR" { to save it again under the same name after the code } { was added, deleted etc, type: } !SAVE@"COLOR" There is another way to save, but it's "whywouldanyonewannadoit" style. Still remembering .OBJ M ? Okey, now instead of M {which stands for Memory }, you could also do: .OBJ "MYCODE" And all your code is going straight forward to a disk to be saved. Nothing to compile here, of course. 9. Type !LOAD"(program name)", e.g. !LOAD"COLOR" { won't work because it's already in the memory } { but this is how you load it } { notice no usage of ,8 or ,8,1 } And now what we all have been waiting for: 10 Type !ERASE"COLOR" to delete it and it's gone. { typing !DISPLAY can confirm it if you're a non-believer } { now you could load it, but don't, we are moving on! } {!ERASE is also used to delete lines or a block of lines } {!ERASE 20,30 will delete lines between 20 & 30 including 20 & 30 } ---------------------------------------------------------------------------------------------------------------------------- ************************************************************************* * * * DO THIS BEFORE YOU CONTINUE! * * If not already running! * * Load and run SFK.BAS, assign a project name to function keys and * * enjoy comfortable working with Edass 128. * * * ************************************************************************* *** SFK.BAS is a little program and has a purpose to help you *** ****** set the function keys ****** ************************************************************************* * * * Example: * * Version 1.0 { e.g. helloworld project } * * * * F1 key :!begin"helloworld.asm" * * F2 key :!edit"helloworld.asm" * * F3 key :!exit * * F4 key :!assembler"helloworld.asm" * * F5 key :!go$1300 * * F6 key :!display * * F7 key :!load"helloworld.asm" * * F8 key :!save"helloworld.asm" * * * * NOTE 1: To reassign old C128 F-Key values, just bload DEF-SFK.BL * * from floppy and type SYS 2024 * * NOTE 2: If you rename your project, start SFK.BAS again * * and assign this new name to function keys. * * NOTE 3: If you load your existing source code, no need to do * * !begin"...", it is like included with !load"..." * * and you'll need the !edit command. * ************************************************************************* Now modify the screen view to make it more comfortable to work with on 40 columns screens. NOTE: I did that already and it's default now. You can change it to whatever you prefer and save it then to have it as your default setting. { do this when Edass 128 is already running, of course } Type !MOD Column,Color e.g. !MOD 47 { good value for 40-column screens } Type !STORE to save it for the next time { have the disk in where Edass 128 is on it! } { so it can be saved there and loaded the next time } - - - ********************************************************************************* * IMPORTANT! * * In case you just jumped over EVERYTHING, YOU NASTY ONE! to this examples * * section, load and run Edass 128 first! Load SFK.BAS & assign * * helloworld.asm as a project name to FunctionKeys * * { see little above, it won't break your neck! } * ********************************************************************************* ---------------------------------------------------------------------------------------------------------------------------- EXAMPLE 2:HELLOWORLD.ASM| | ------------------------| | Description: Guess that's the mandatory one! 1000 ways to do it, here is one. | | | --------------------------------------------------------------------------------| 1. boot Edass 128 and load and run SFK.BAS | 2. add HELLOWORLD.ASM as a project name | 3. press { F1 } !begin"HELLOWORLD.ASM" and press ENTER | 4. press { F2 } !edit"HELLOWORLD.ASM" and press ENTER | 5. copy/paste this code below to VICE C128 emulator | {or type it in, if you prefer! i had no choice } | --------------------------------------------------------------------------------- helloworld.asm -a:0010-a: -e: *= $1300 .obj m .bank 15 lda #$0e ;lower charset jsr $ffd2 lda #$93 ;clear screen jsr $ffd2 ldx #$00 getmore lda hi,x sta $0400+(40*12)+40-11,x inx cpx #$0b bne getmore lda #$0e jsr $ffd2 rts hi .text "hello world" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> Now hit { F3 } !EXIT { F4 } !ASSEMBLER"HELLOWORLD.ASM" { F5 } !GO$1300 { F8 } !SAVE"HELLOWORLD.ASM", add @ to overwrite it in cases of code changes !SAVE@""HELLOWORLD.ASM" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><>. - - - ---------------------------------------------------------------------------------------------------------------------------- EXAMPLE 3: KEYDOWN.ASM | | ------------------------| | Description: Press RETURN or ENTER key to proceed. | | | --------------------------------------------------------------------------------| 1. boot Edass 128 and load and run SFK.BAS | 2. add KEYDOWN.ASM as a project name | 3. press { F1 } !begin"KEYDOWN.ASM" and press ENTER | 4. press { F2 } !edit"KEYDOWN.ASM" and press ENTER | 5. copy/paste this code below to VICE C128 emulator | {or type it in, if you prefer! i had no choice } | --------------------------------------------------------------------------------- keydown.asm -e:0010-a: -e: ; press enter/return to exit ; *= $1300 .obj m .bank 15 lda #$93 ;clear screen jsr $ffd2 lda #14 ; low char set jsr $ffd2 ; 142 is high loop jsr $ffe4 ; read key cmp #$d ; return key? beq exit ; if yes, exit jmp loop exit ldx #$00 ; show rom msg line lda $41bf,x sta $0401,x inx cpx #$26 bne line rts <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> Now hit { F3 } !EXIT { F4 } !ASSEMBLER"KEYDOWN.ASM" { F5 } !GO$1300 { F8 } !SAVE"KEYDOWN.ASM", add @ to overwrite it in cases of code changes !SAVE@""KEYDOWN.ASM" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><>. - - - ---------------------------------------------------------------------------------------------------------------------------- EXAMPLE 4: DELAY.ASM | | ------------------------| | Description: Let's delay this fancy color cycle and character deletion. | | | --------------------------------------------------------------------------------| 1. boot Edass 128 and load and run SFK.BAS | 2. add DELAY.ASM as a project name | 3. press { F1 } !begin"DELAY.ASM" and press ENTER | 4. press { F2 } !edit"DELAY.ASM" and press ENTER | 5. copy/paste this code below to VICE C128 emulator | {or type it in, if you prefer! i had no choice } | --------------------------------------------------------------------------------- delay.asm -a:0011-a: -e: *= $1300 ;start address .obj m .bank 15 ;------------------- screen = $0400 ;screen dec 1024 ;------------------- jsr prefs ldx #$00 data txa sta screen,x ;add some chars inx ;to the screen cpx #$28 ;values are used bne data ;for color-cyle ;------------------- ldx #$00 loop lda screen,x ;read screen sta $d020 ;and add values jsr delay ;to the color inx ;register $d020 lda #$20 ; sta screen-1,x ;del chars cpx #$29 ;one by one? bne loop lda #$0c sta $d020 lda #$0b sta $d021 rts ;back to basic ;------------------- delay ldy #$80 ;and our delay waity lda #$28 ;routine waitras cmp $d012 ; bne waitras ;the best cleaner dey ;hmmm, sorry... bne waity ;delay routine rts ;in the world ;------------------- prefs lda #$0e ;small char-set jsr $ffd2 lda #$93 ;clear screen jsr $ffd2 rts <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> Now hit { F3 } !EXIT { F4 } !ASSEMBLER"DELAY.ASM" { F5 } !GO$1300 { F8 } !SAVE"DELAY.ASM", add @ to overwrite it in cases of code changes !SAVE@""DELAY.ASM" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> ---------------------------------------------------------------------------------------------------------------------------- EXAMPLE 5: COUNTER.ASM | | ------------------------| | Description: Ever wanted your own easy to use counter, suitable to be a perfect | high score counter for a game you always wanted to make. | And it's so easy that even your parents could make a 1 billion counter out of it| --------------------------------------------------------------------------------| 1. boot Edass 128 and load and run SFK.BAS | 2. add COUNTER.ASM as a project name | 3. press { F1 } !begin"COUNTER.ASM" and press ENTER | 4. press { F2 } !edit"COUNTER.ASM" and press ENTER | 5. copy/paste this code below to VICE C128 emulator | {or type it in, if you prefer! i had no choice } | --------------------------------------------------------------------------------- counter.asm -a:0011-a: -e: *= $1300 ;start address .obj m .bank 15 ; ;the absolute first ;no rocket science ;counter which can ;be extended with ;ease to count even ;billions if needed ;------------------- ; screen = $0400 ;------------------- jsr prefs ;------------------- ;counter position ;------------------- pos1 = screen+2 ;last(first) dig pos2 = screen+1 ;2nd digit pos3 = screen+0 ;start pos. 3rd ;------------------- ;fill the positions with zero ;------------------- lda #$30 ldx #$00 set sta pos3,x inx cpx #$03 bne set ;------------------- ;call the counter ;in an endles loop ;just for the example ;you can call it with 'jsr counter' ;for your purposes ; ; ** stop with enter/return key ** ; ;------------------- loop jsr counter jsr delay jmp loop ;------------------- quit lda #$0c ; back to basic sta $d020 lda #$0b sta $d021 rts ;------------------- ;counter start ;------------------- counter clc lda pos1 adc #$01 sta pos1 cmp #$3a ; ready to jump? beq digit2 ; do it! rts ;------------------- digit2 lda pos2 ; this is 10... sbc #$01 adc #$01 sta pos2 cmp #$3a ; 99 reached? beq digit3 ; next digit then lda #$30 ; reset pos1 sta pos1 ; to zero rts ;------------------- digit3 lda pos3 sbc #$01 adc #$01 sta pos3 cmp #$3a ; reset all to 0 beq creset ; 1000 reached lda #$30 sta pos2 sta pos1 rts ;------------------- creset lda #$30 sta pos3 sta pos2 sta pos1 lda #128 ; small random sta $d412 ; number lda $d41b ; generator tax ; to cycle stx $d020 ; colors rts ;------------------- ; subroutines ;------------------- prefs lda #$0e ; small char-set jsr $ffd2 lda #$93 ; clear screen jsr $ffd2 rts ;------------------- delay ldx #$50 ; and our delay w1 ldy #$20 ; machinery w2 dey ; bne w2 ; dex ; bne w1 ; rts ; <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> Now hit { F3 } !EXIT { F4 } !ASSEMBLER"COUNTER.ASM" { F5 } !GO$1300 { F8 } !SAVE"COUNTER.ASM", add @ to overwrite it in cases of code changes !SAVE@""COUNTER.ASM" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> ---------------------------------------------------------------------------------------------------------------------------- EXAMPLE 6: COLORRUN.ASM | | ------------------------| | Description: Colors, what else... And you'll learn a few things or more... | Most important is to understand why it's doing exactly what | you'll see here in this example. $d3 is a register where you can | read SHIFT, CTRL, ALT, C= key pressing. | Try (in BASIC): 10 char 0,0,0,"":print peek (dec("d3")):goto 10 | --------------------------------------------------------------------------------| 1. load Edass 128 and run SFK.BAS | 2. add COLORRUN.ASM as a project name | 3. press { F1 } !begin"COLORRUN.ASM" and press ENTER | 4. press { F2 } !edit"COLORRUN.ASM" and press ENTER | 5. copy/paste this code below to VICE C128 emulator | {or type it in, if you prefer! i had no choice } | --------------------------------------------------------------------------------- colorrun.asm -e:0011-a: -e: *= $1300 ; start address .obj m .bank 15 ;------------------- screen = $0400 color = $d800 ;------------------- jsr prefs ;------------------- ;text message ldx #$27 ; counter read jsr delay lda msg,x ; msg location sta screen,x ; screen position dex bpl read ;-------------------- ;color world lda #$00 ; black screen sta $d020 sta $d021 ;colors for the characters ldx #$00 ; counter to 0 loop lda col,x ; get colors sta color,x ; store them in jsr delay ; color matrix inx cpx #$28 bne loop ;------------------- ;play wild ;------------------- more ldx #$00 ; counter to 0 load jsr feed ; get & store sta rndcol,x ; rnd colors lda msgout,x ; show the 2nd sta screen+90,x ; 3rdline lda rndcol,x ; load rnd colors sta color+90,x ; store in col jsr fastcol ; screen matrix inx cpx #$14 bne load ; loop lda $d3 ; is shift hit? cmp #$01 ; yes beq end ; back to basic jmp more ; else loop more! ; end rts ; over and out ;------------------- prefs lda #$0e ; small char-set jsr $ffd2 lda #$93 ; clear screen jsr $ffd2 rts ;------------------- delay ldy #$00 ; and our delay w1 lda #$30 ; routine w2 cmp $d012 ; bne w2 ; iny ; cpy #$30 ; bne w1 ; rts ; go back ;------------------- fastcol ldy #$00 ; shorter w3 lda #$02 ; delay for color w4 cmp $d012 ; cycle bne w4 iny cpy #$05 bne w3 rts ;------------------- ;feed rndcol with random values feed lda #$ff sta $d40e sta $d40f lda #$80 sta $d412 lda $d41b ; read this rts ;------------------------------------ ;------------------------------------ ;------------------------------------ msg .text "** commodore 128! <>" .text " why 1mhz!!? only **" msgout .text "" ; col .byte $05,$05,$05,$05,$05 .byte $07,$07,$07,$07,$07 .byte $0a,$0a,$0a,$0a,$0a .byte $0d,$0d,$0d,$0d,$0d .byte $0e,$0e,$0e,$0e,$0e .byte $04,$04,$04,$04,$04 .byte $08,$08,$08,$08,$08 .byte $0f,$0f,$0f,$0f,$0f ; ;these are space holders where we are ;adding and reading random numbers ;to generate random color cycles. ;as you can see, easy to do! ; rndcol .byte 0,0,0,0,0,0 <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> Now hit { F3 } !EXIT { F4 } !ASSEMBLER"COLORRUN.ASM" { F5 } !GO$1300 { F8 } !SAVE"COLORRUN.ASM", add @ to overwrite it in cases of code changes !SAVE@""COLORRUN.ASM" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> ---------------------------------------------------------------------------------------------------------------------------- EXAMPLE 7: MYNAMEIS.ASM | ********************************************************************************| Description: It's always good to know with whom we are dealing, right? | This small routine just want your name. And it will be saved | locally for further usage (e.g. possible game). | Very handy indeed! | Just add a name, don't drive around with arrow keys... hahaha... | I bet you'll do exactly that now! | --------------------------------------------------------------------------------| 1. load Edass 128 and run SFK.BAS | 2. add MYNAMEIS.ASM as a project name | 3. press { F1 } !begin"MYNAMEIS.ASM" and press ENTER | 4. press { F2 } !edit"MYNAMEIS.ASM" and press ENTER | 5. copy/paste this code below to VICE C128 emulator | {or type it in, if you prefer! i had no choice } | --------------------------------------------------------------------------------- mynameis.asm -a:0011-a: -e: *= $1300 ; start address .obj m .bank 15 ;------------------- screen = $0400 ;------------------- ;main calling of the subroutines ; jsr prefs jsr ask jsr cursor input jsr $ffcf cmp #$0d ;check for beq cont ;return bne input ;jump to move cont jsr getname ;on (or loop) rts ;back to BASIC ;------------------- prefs lda #14 ;lowerchar-set jsr $ffd2 jsr $c8bf ;reverse off lda #$93 ;clear screen jsr $ffd2 lda #$0b ;grey screen sta $d020 ;color sta $d021 rts ;------------------- delay ldy #$a0 ;and our delay w1 lda #$80 ;routine w2 cmp $d012 ; bne w2 ; dey ; bne w1 ; rts ; ;------------------- conoff lda #$00 ;enable sta $0a27 ;cursor rts ;unused ;------------------- ask ldx #$00 write lda asking,x sta screen+(5*40)+4,x inx cpx #$12 bne write rts ;------------------- cursor clc ;clear carry ldx #$06 ;y pos ldy #$04 ;x jsr $cc6a ;set cursor rts ;------------------- getname lda #$05 ; well known sta $d020 ; all this ldx #$00 ; below loadname lda screen+(6*40)+4,x sta name,x inx cpx #$0f bne loadname ;------------------- ldx #$00 show lda name,x sta screen+(5*40)+22,x inx cpx #$0f bne show ;------------------- delete ldx #$00 lda #$20 ;space key del sta screen+(6*40),x inx cpx #$28 bne del rts ;------------------- asking .text "your name please: " name .byte 0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0 <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> Now hit { F3 } !EXIT { F4 } !ASSEMBLER"MYNAMEIS.ASM" { F5 } !GO$1300 { F8 } !SAVE"MYNAMEIS.ASM", add @ to overwrite it in cases of code changes !SAVE@""MYNAMEIS.ASM" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> ---------------------------------------------------------------------------------------------------------------------------- EXAMPLE 8: SPRITES.ASM | ********************************************************************************| Description: What took us so long to deal with sprites? | Not so important. We are here now and let us get busy and create | some nice sprites and put them on the screen. | sta $12fd is important address. If not disabled, you won't see | any sprites because BASIC is going to have them under control. | For assembly access to sprites, this address must be non-zero | e.g. lda #$01:sta $12fd | --------------------------------------------------------------------------------| 1. load Edass 128 and run SFK.BAS | 2. add SPRITES.ASM as a project name | 3. press { F1 } !begin"SPRITES.ASM" and press ENTER | 4. press { F2 } !edit"SPRITES.ASM" and press ENTER | 5. copy/paste this code below to VICE C128 emulator | {or type it in, if you prefer! i had no choice } | --------------------------------------------------------------------------------- sprites.asm -a:0011-a: -e: *= $1300 .obj m .bank 15 ;-------------------- jsr spron loop jsr $ffe4 ;wait on return cmp #$0d ;key beq out ;end exit jmp loop out lda #$00 ;enable basic sta $12fd ;interrupt lda #142 jsr $ffd2 rts ;go to basic ; spron lda #$0b ;screen color sta $d021 ;grey sta $d020 lda #$08 ;text color sta $f1 ; lda #$93 ;clr screen jsr $ffd2 lda #$fe ldx #$00 sprites sta $0e00,x ;with value #254 inx cpx #196 bne sprites lda #$07 ;sprite 1,2,3 on sta $12fd ;basic irq off sta $d015 ;bit 1+2+4 = 7 ; lda #80 ;position x spr1 sta $d000 lda #97 ;position y spr1 sta $d001 ; lda #160 ;position x spr2 sta $d002 lda #118 ;position y spr2 sta $d003 ; lda #240 ;position x spr3 sta $d004 lda #118 ;position y spr3 sta $d005 ; lda #$01 ;sprite 1 sta $d017 ;resize sta $d01d sta $d01b ;behind text lda #$07 ;yellow sta $d027 lda #14 jsr $ffd2 ldx #$00 get lda $41bf,x inx sta $0400+(8*40),x sta $0402+(9*40),x sta $0401+(10*40),x cpx #$26 bne get rts <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> Now hit { F3 } !EXIT { F4 } !ASSEMBLER"SPRITES.ASM" { F5 } !GO$1300 { F8 } !SAVE"SPRITES.ASM", add @ to overwrite it in cases of code changes !SAVE@""SPRITES.ASM" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> ---------------------------------------------------------------------------------------------------------------------------- EXAMPLE 9: SPRITEANIM.ASM | ********************************************************************************| Description: And a little sprite animation. Sprite created by me (cool) and | this little animation too. So it's not internet copy/past version. | It's simple, but it'll give you an idea of what more can be done. | --------------------------------------------------------------------------------| 1. load Edass 128 and run SFK.BAS | 2. add SPRITEANIM.ASM as a project name | 3. press { F1 } !begin"SPRITEANIM.ASM" and press ENTER | 4. press { F2 } !edit"SPRITEANIM.ASM" and press ENTER | 5. copy/paste this code below to VICE C128 emulator | {or type it in, if you prefer! i had no choice } | --------------------------------------------------------------------------------- spriteanim.asm -e:0011-a: -e: *= $1300 .obj m .bank 15 ;-------------------- jsr spron loop jsr $ffe4 ;wait on return cmp #$0d ;key beq out ;end exit jsr spranim ;call animation jmp loop out lda #$00 ;enable basic sta $12fd ;interrupt again rts ;go to basic ; spron lda #$0b ;screen color sta $d021 ;grey sta $d020 lda #$08 ;text color sta $f1 ; lda #$93 ;clr screen jsr $ffd2 ; ldx #$00 ;get sprites sprites lda mkspr,x ;read sta $0e00,x ;byte data inx cpx #$ff bne sprites lda #$01 ;sprite 0 on sta $12fd ;bit 1 sta $d015 lda #$80 ;position x spr0 sta $d000 lda #$64 ;position y spr0 sta $d001 ; lda #$01 sta $d017 ;resize y lda #$01 sta $d01d ;resize x sta $d01b ;before text ; lda #$01 ;multicolor spr0 sta $d01c lda #$00 ;color 1 sta $d027 lda #$01 ;multicolor 0 sta $d025 lda #$02 ;multicolor 1 sta $d026 ;mc is equal for nop ;all sprites ldx #$27 street lda #$68 ;draw our street sta $0400+(12*40),x lda #$0c sta $d800+(12*40),x dex bpl street lda #$06 sta $d020 rts ;-------------------- spranim ldx #$00 ;counter motion lda anim,x ;load pointer 0 sta $07f8 ;for sprite 0 inx jsr delay cpx #$3 ;pointer 3 bne motion ;for sprite 0 rts ;-------------------- delay ldy #00 ;delay anim a wait iny ;little bit lda #$50 raster cmp $d012 bne raster cpy #$25 bne wait rts ;-------------------- ;anim pointers ;e.g. sprite location $0e00, dec 3584 ;first pointer $38, dec 56 ;means 56*64 (1 spr = 64 bytes) ;is equal to 3584, ergo sprite 0 ;same sprite, but pointer $39, dec 57 ;and so on, is creating an animation ; anim .byte $38,$39,$3a,$3b ; mkspr .byte $00,$ff,$00,$03,$ff,$00,$03,$94 .byte $00,$0f,$74,$00,$0c,$55,$00,$00 .byte $50,$00,$00,$94,$00,$00,$30,$00 .byte $00,$98,$00,$00,$dc,$00,$00,$d4 .byte $ac,$00,$f5,$aa,$00,$fd,$60,$00 .byte $fc,$40,$00,$b8,$80,$00,$20,$00 .byte $00,$20,$00,$00,$20,$00,$00,$20 .byte $00,$00,$10,$00,$00,$14,$00,$00 .byte $00,$ff,$00,$03,$ff,$00,$03,$94 .byte $00,$0f,$74,$00,$0c,$55,$00,$00 .byte $50,$00,$00,$94,$00,$00,$30,$00 .byte $00,$98,$00,$00,$dc,$00,$00,$d4 .byte $ac,$00,$f5,$aa,$00,$fd,$60,$00 .byte $fc,$40,$00,$b8,$80,$00,$20,$00 .byte $00,$20,$00,$00,$20,$00,$01,$88 .byte $00,$01,$04,$00,$00,$45,$00,$00 .byte $00,$ff,$00,$03,$ff,$00,$03,$94 .byte $00,$0f,$74,$00,$0c,$55,$00,$00 .byte $50,$00,$00,$94,$00,$00,$30,$00 .byte $00,$98,$00,$00,$dc,$00,$00,$d4 .byte $ac,$00,$f5,$aa,$00,$fd,$60,$00 .byte $fc,$40,$00,$b8,$80,$00,$20,$00 .byte $00,$a8,$00,$00,$82,$00,$01,$02 .byte $00,$04,$01,$00,$04,$01,$40,$00 .byte $00,$ff,$00,$03,$ff,$00,$03,$94 .byte $00,$0f,$74,$00,$0c,$55,$00,$00 .byte $50,$00,$00,$94,$00,$00,$30,$00 .byte $00,$98,$00,$00,$dc,$00,$00,$d4 .byte $ac,$00,$f5,$aa,$00,$fd,$60,$00 .byte $fc,$40,$00,$b8,$80,$00,$20,$00 .byte $00,$20,$00,$00,$20,$00,$01,$88 .byte $00,$01,$04,$00,$00,$45,$00,$00 <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> Now hit { F3 } !EXIT { F4 } !ASSEMBLER"SPRITEANIM.ASM" { F5 } !GO$1300 { F8 } !SAVE"SPRITEANIM.ASM", add @ to overwrite it in cases of code changes !SAVE@"SPRITEANIM.ASM" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> ---------------------------------------------------------------------------------------------------------------------------- EXAMPLE 10: CHARATERIAM.ASM | ********************************************************************************| Description: We are making a copy of first 64 characters from ROM to RAM at the | location hex $2000 or dec 8192. To make some room we are shortly activating high| resolution screen and return back to normal screen. This is making sure BASIC | start address is moved to a new location $4000, high resolution screen is | starting from $2000, ergo, where our characters are. Also meaning you can use | a space after the character transfer from $2200 - $3fff for your machine | language code, unless you want to transfer and use more character. Actually, | for an easy game, few levels, 64 character are enough. | But of course, you can add a few characters more just for the level design. | { see next example, only on disk Edass128Sources.d64, gameon.asm file } | What you could do is turn on this new character set with poke 2604,24 and then | draw your level, e.g. the first 15 lines { more than enough for some swifty game| with nice level design } and then save it with starting address $2300 as: | bsave"level1",b15,p1024top1024+600 { 1st 15 lines, 15x40 = 600 } | bsave"level1col",b15,p55296top55296+600 {to save also the used colors } | You could then do the same for all levels and just load them into memory, each | on it's own location, bsave that area with bsave again and have them ready all | all at once with single bload command. Later you can access levels you want | very quickly without a need to bload them individually. | --------------------------------------------------------------------------------| 1. load Edass 128 and run SFK.BAS | 2. add CHARATERIAM.ASM as a project name | 3. press { F1 } !begin"CHARATERIAM.ASM" and press ENTER | 4. press { F2 } !edit"CHARATERIAM.ASM and press ENTER | 5. copy/paste this code below to VICE C128 emulator | {or type it in, if you prefer! i had no choice } | --------------------------------------------------------------------------------- *= $1300 .obj m .bank 15 ; ;project: characteriam.asm ; ;set variable charmod = $2000 base = $400 color = $d800 ; ;------------------------------ ;what is it doing? ;transfer rom characters ;to ram. just 64 uppercase characters ;starting $2000, dec 8192 ;------------------------------ ; ; ;***** important: basic space ***** ;***** reduced to only 2kb ***** ;** due to Edass 128 environment ** ; ;** sfk128.bas can get messed up ** ;* with default Edass128 settings * ;** check Edass 128 !new command ** ; ; ;make highres memory ready ;basic source code moved to $4000 ; jsr init ;char transfer jsr create jsr seeit mloop jsr $ffe4 cmp #$0d ;enter pressed beq out ;adios then jmp mloop out lda #$14 ;set normal char sta $a2c ;pointer lda #$93 ;clear screen jsr $ffd2 lda #$0c sta $d020 lda #$0b sta $d021 lda #$08 sta $f1 rts ;return to basic ; init lda #$ff ;interrupt off sta $d8 lda #$3b ;bitmap on sta $d011 lda #$1b ;bitmap off sta $d011 lda #$00 ;interrupt on sta $d8 ; ; ;switch to bank 14 ;and do the transfer of all ;characters ; lda #$01 ;bank 14 sta $ff00 ;where character ldx #$00 ;rom is get lda $d000,x ;transfer to ram sta $2000,x ;location 8192 lda $d0ff,x ;hex $2000 sta $20ff,x ;64 characters inx cpx #$ff bne get ;loop until done ; ldx #$00 ;to transfer the all lda $d1fe,x ;remaning bits sta $21fe,x inx cpx #$02 bne all ; ;back to bank 15 ; lda #$00 ;activate bank 15 sta $ff00 ;again sta $d020 ;black screen sta $d021 ; ;set pointer ; lda #$18 ;point to the new sta $0a2c ;char location ; ;show character set (64 characters) ; ldx #$40 show dex txa sta base,x bne show rts ; ;modifiy @, at $2000 location ; create ldx #$00 nchar lda char1,x sta charmod,x inx cpx #$08*13 bne nchar rts ; seeit ldx #$00 level lda my0,x sta base+(40*15),x lda #$02 sta color+(40*15),x ;with for next loop not based on 40 ;characters this would be more cycle ;friendly, but...hahaha lda my1,x sta base+(40*16),x sta base+(40*17),x sta base+(40*18),x lda #$0c sta color+(40*16),x lda #$0d sta color+(40*17),x lda #$0c sta color+(40*18),x inx cpx #$28 bne level rts ;@,a,b,c,d,e,f chr .byte $ff,$81,$81,$81,$81,$81,$81,$ff .byte $7e,$c3,$bd,$8d,$85,$a1,$c1,$7e .byte $7f,$c0,$81,$80,$a0,$98,$c0,$7f .byte $fe,$03,$f9,$3d,$0d,$01,$03,$fe .byte $ff,$81,$bd,$8d,$85,$a1,$81,$ff .byte $ff,$80,$81,$80,$a0,$b0,$80,$ff .byte $ff,$01,$fd,$3d,$0d,$01,$01,$ff ;g,h,i,j,k,l .byte $04,$6a,$10,$3c,$66,$76,$7e,$3c .byte $ff,$80,$90,$92,$bf,$88,$80,$ff .byte $ff,$01,$79,$cd,$ed,$79,$01,$ff .byte $24,$99,$24,$db,$24,$db,$24,$db .byte $18,$3c,$18,$18,$18,$3c,$7e,$ff .byte $ff,$18,$3c,$ff,$3c,$18,$7e,$18 ; ;example ; my0 .byte $07,$20,$07,$20,$07,$07,$07,$20 .byte $07,$20,$07,$20,$07,$07,$07,$20 .byte $07,$20,$07,$07,$07,$07,$07,$07 .byte $07,$20,$20,$20,$20,$07,$07,$20 .byte $07,$20,$20,$20,$20,$07,$07,$20 my1 .byte $02,$03,$02,$03,$02,$03,$02,$03 .byte $02,$03,$02,$03,$02,$03,$02,$03 .byte $02,$03,$02,$03,$02,$03,$02,$03 .byte $02,$03,$02,$03,$02,$03,$02,$03 .byte $02,$03,$02,$03,$02,$03,$02,$03 <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> Now hit { F3 } !EXIT { F4 } !ASSEMBLER"CHARATERIAM.ASM" { F5 } !GO$1300 { F8 } !SAVE"CHARATERIAM.ASM", add @ to overwrite it in cases of code changes !SAVE@""CHARATERIAM.ASM" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> ---------------------------------------------------------------------------------------------------------------------------- EXAMPLE 11: GAMEON.ASM - AVAILABLE ONLY ON DISK .d64, Edass128Sources.d64 | ********************************************************************************| Description: Previous example is a bit extend and we are adding more characters | and modifying graphics characters instead. Please check C128 | department for additional info. This example is available only on | disk Edass128Sources.d64, gameon.asm | Also included is dlevel.bl file and dlevelcol.bl which you must | bload, e.g. bload"dlevel.bl" and bload"dlevelcol.bl" | HOWEVER! Before you do that, make sure you installed Edass 128 | and loaded !load"gameon.asm" and have it started with !go$1300 | With poke 2604,24 and poke 2604,20 you can switch between character| sets. | Modified graphic elements are reflecting the alphabet, just with | pressed SHIFT button. e.g. SHIFT + A,B,C etc. | New Character set: poke 2604,24 | Standard Character set: poke 2604,20 | Basic Start Address is moved to: $4000 | Number of transferred Characters: #92 | End address hex / dec: $22e2 / 8928 | Free for assembly: $2300 to $3fff | IMPORTANT! Because high resolution area is used for the character modification| do not use graphic command or clear graphic area. | All will be gone!!! | Edass is occupying that area too as default settings. | Meaning only 2KB are free for BASIC Source text | Can be changed with !new Edass 128 command. | --------------------------------------------------------------------------------- <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> Now hit { F3 } !EXIT { F4 } !ASSEMBLER"GAMEON.ASM" { F5 } !GO$1300 { F8 } !SAVE"GAMEON.ASM", add @ to overwrite it in cases of code changes !SAVE@""GAMEON.ASM" <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><> **************************************************************************************************************** ******************************************** *********************************************** ******************************************** BIG BONUS CONTENT *********************************************** ******************************************** *********************************************** **************************************************************************************************************** THE C128 BANK(ruptcy) BASIC Command { BANK bank number } BANK 15 Edass .BANK 15 *************************************************************************** THE NIGHTMARE OF EVERY : From time to time C128 USER -> 100% guaranteed! *************************************************************************** MMU CONFIG REGISTER ------------------------------ |Contents of $D000-$DFFF | |0 - I/O block | |1 - RAM or ROM | |(according to selection 5-4 | -----------------------------| | | |-----------------------------------------------------------------------------------------------| Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |---------------|-------------|-----------------|-------------|-----------------|-------|-------| | | | | ------|------ -------------|---------------- -----------|----------------- | |{RAM BLOCK}| | CONTENTS OF $C000-$FFFF | |Contents of $8000-$BFFF | | |00 - 0 | | 00 - Kernal & Character ROM | |00 - BASIC & ML Monitor ROM| | |01 - 1 | | 01 - Internal Function ROM | |01 - Internal Function ROM | | |10 - 2 | | 10 - External Function ROM | |10 - External Function ROM | | |11 - 3 | | 11 - RAM | |11 - RAM | | ------------- | Bit 0 determinates the | ----------------------------- | | content of $D000-$DFFFF| -----------------|-------- ------------------------------ |Contents of $4000-$7FFF | |0 - BASIC ROM (low) | |1 - RAM | -------------------------- **************************************************************************************************************** For those who can't read, here the 'graphical' illustration { as good as possible }. { I am counting in here because I can 'read' more out of one picture than from 1000 books with 1000 pages each } This is a nice little illustration you have seen many times, but not this one, this one is mine, mine, mine...haha! BANK 0 BANK 1 BANK 14 | BANK 15 | RAM BLOCK {64KB} | RAM BLOCK {64K} | ROM BLOCK {48K} $FFFF - |-------------------------|-------------------------|-------------------------| - $FF00 MMU | | | | - $FF0F REGISTERS |-------------------------|-------------------------|-------------------------| | | | | $FF00 - |-------------------------|-------------------------|-------------------------| { Place of } | | | | { sleeping } | | | KERNAL ROM | - { subroutines } | | | | { Oh Yeah! } $E000 - | | |-------------------------| _ $E000 KERNAL $DC00 - | | | |-----------| | | | Character |-----------|_ $D800 COLOR AREA | | | ROM | I/O BLOCK | | | | | | | | |-------------------------|_ $D000 I/O BLOCK | | | 40/80 COLUMN SCREEN | | | | EDITOR | | | |-------------------------|_ $C000 Screen Editor | | |-------------------------|_ $B800 ML Monitor | | | HIGH BASIC OR | | | | CARTRIDGE ROM | $8000 | | |-------------------------| | | | LOW BASIC | | | | OR | | | | CARTRIDGE ROM | $4000 - |-------------------------| |-------------------------|_ $4000 | 40 COLUMN GRAPHIC | | WHY THE HECK | | SCREEN MEMORY | | IS THIS | | OR BASIC SOURCE CODE | | TOTALLY UNUSED? | | ($1C01 to $3FFF) | | ??? | |-------------------------| | ??? | | BASIC & | | ??? | | KERNAL ROM | | | |-------------------------| | NOBODY KNOWS! | | 40-COLUMN SCREEN | | NOBODY KNOWS! | | (Poke 1024,1) | | NOBODY KNOWS! | |-------------------------| | REALLY? | |-------------------------|-------------------------| | |-------------------------|-------------------------|-------------------------| ZeroPage is here somewhere, collecting dust ;-) **************************************************************************************************************** ******************************************** *********************************************** ******************************************** BIG BONUS CONTENT *********************************************** ******************************************** *********************************************** ****************************************************************************************************************