0 Members and 3 Guests are viewing this topic.
Quote from: Builderboy on August 22, 2010, 08:42:21 pmIm curious as to what happens if you have a second page with only data and no actual code?You could probably theortically access this data, but if so it's a lot more complicated than meets the eye. If you try to access it simply by using code from your first page, you could crash your calculator. It's much easier to load it with your own code on the data page.
Im curious as to what happens if you have a second page with only data and no actual code?
Quote from: Hot_Dog on August 22, 2010, 08:47:53 pmQuote from: Builderboy on August 22, 2010, 08:42:21 pmIm curious as to what happens if you have a second page with only data and no actual code?You could probably theortically access this data, but if so it's a lot more complicated than meets the eye. If you try to access it simply by using code from your first page, you could crash your calculator. It's much easier to load it with your own code on the data page.that's: ouch. So basically you can't have a game engine on page 0 and game data on page 1. That sucks, leads to alot of duplicate code i guess...or am I misunderstanding?
#include "ti83plus.inc"#include "app.inc"defpage(0, "MyApp");for bcallin_AddHLOne .equ $ - $4000.dw AddHLOne ;i think address comes first....db 1;all code on page 0 goes here ld hl,0 bcall(_AddHLOne) bcall(_JForceCmdNoChar)defpage(1);oh look an incredibly efficient routine on page 1 :DAddHLOne: ld de,1 add hl,de ;lalala ret ;impossible to optimize btw ;)validate()
spasm -T -L infile.asm outfile.8xk
.binarymode ti8xapp.variablename "outfile"#include "ti83plus.inc".defpage 0,$4000,$4000 ;Define pages 0 and 1.defpage 1,$4000,$4000.page 0 ;Page 0 goes here.block 128 ;Set aside 128 bytes for the header jp Start ;Jp over the branch table .branch AddHLOneStart ;Colons after labels are optional ld hl,0 bcall(_AddHLOne) bcall(_JForceCmdNoChar).page 1 ;Page 1 code goes hereAddHLOne ld de,1 add hl,de ret
brass infile.asm
ld (saveSP), hl ld a, 1 out (05), a ;puts ram page 1 in $C000, (it's usually page 0) in a, (06) inc a out (07), a ;puts second page of app in $8000 ld sp, textShadow+$4000 ;anywhere will work as long as it's free;now you access your variables+$4000 because they;are swapped into $C000 instead of $8000 ld a, 4 ld (enemies+$4000), a;even cooler yet, you can put ram routines way out in the;$C000 region and execute them ld hl, doStuff ld de, statVars+$4000 ld bc, doStuffEnd-doStuff ldir call statVars+$4000;or you can call a routine on the second half of your app call secondPageRoutine ;it's address is ($9123) or something ld a, $81 out (07), a ;ram page 1 xor a out (05), a ;ram page 0 ld sp, (saveSp) retdoStuff: ld a, 5 retdoStuffEnd:
There is another hacky way that you can get info off the second page of your app, or any flash page for that matter.
JumpToLabelPage2 = $ - $4000 .dw $4000 ; <-- if its the first line of page2, it'd be this. How do I know the offset of labels ? .db 1 ; further down the programm?;And mods, I didn't put the big empty space down here?
#DEFINE NOAPPHEADER#INCLUDE "DWEDIT.INC"...Long list of #defines and .equs...FirstLabel: ; When I need to call this one it's easy, gotta fill in $4000 and it works ; Becomes a problem when I need the offset of"labels further down.
author=calcdude84se link=topic=4102.msg57402#msg57402 date=1282575320]Ah, that's the problem. Since they're assembled one page at a time, each page is unaware of the other's labels.
JumpToLabelPage2 = $ - $4000 .dw $4000 .db 1