0 Members and 3 Guests are viewing this topic.
*some codes* CALL newsprr1n1 ;Just some stuff, not important I think... LD B, 6 ; CALL hidemoveshowncount ; JP Label ;Gets executed, nothing wrong ;But if I do this: *some codes* CALL test123 ;Ram-Reset :C JP Label ;Doesn't get executed. Ram resets the previous line.test123: CALL newsprr1n1 ;The EXACT same stuff! LD B, 6 ; CALL hidemoveshowncount ; ret
;Use this instead of a label in any code that is to be copied somewhere else.#define MAP(name,src,dest) name = ($+0 - src) + dest;This is just a simple copy routine#define COPY(src,dest,size) ld hl,src \ ld de,dest \ ld bc,size \ ldir
call ClearScrnClearScrn: inc a dec hlsmc_Gray= $+1 ld a,%10101010 rrca ld (smc_Gray),a ret
;This should be in the beginning of the program SMCram = appBackupScreen COPY(SMCrom,SMCram,SMCromend-SMCrom);This is how you call the routine (same as before) call ClearScrn;This is the routine that will get copied to ramSMCrom:;Other SMC code can go hereMAP(ClearScrn,SMCrom,SMCram) inc a dec hlMAP(smc_Gray,SMCrom,SMCram)+1 ld a,%10101010 rrca ld (smc_Gray),a ret;The rest of your SMC goes hereSMCromend:
b_call(_PushRealO1) ; First line of the programmstuffstuffstuffLabelQuit: b_call(_PopRealO1) b_call(_ChkFindSym) LD HL, DataStart - $9D95 + 4 ADD HL, DE EX DE, HL LD HL, DataStart LD BC, DataEnd - DataStart LDIR retDataStart:Score1: .DB 0, 0 ; Here goes the stuffPoints2: .DB 0 ; I want to save.DataEnd:
#define VAR(name,size) name: \ .org name+(size)
;Program goes hereld a,(timer)ld (score),hl;End of program;You can use any safe ram for this. This is where the variables get stored..org appBackUpScreen;Declare all variables and appropriate sizesVAR(timer,1)VAR(score,2);This allocates 1 byte to the timer variable and 2 bytes to the score variable.
relocate($4000)relocatedcode: ;code as usual ret end_relocate()
varloc(savesscreen, 768)player_x = var(1) ; 1 byte varplayer_y = var(1)saveHL = var(2); another place varloc(tempswaparea, 323)array = var(500) ; triggers a error
Oh, are they just simple non-executing data? Much simpler! You can create variables in ram instead of in the rom (as long as they fit there) by just defining them to be there. If they need to start initialized with some value, just make sure you initialize it all at the beginning of the program.