Author |
Message |
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 19 Feb 2009 09:51:13 am Post subject: |
|
|
im cloning supaplex (youtube if you dont know what that is)
and i need ALOT of memory for all the levels (there are 111 64*x levels >.>)
so..
how do apps work?
how do i get 2/3k free RAM to decompress data to?
:confused: |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 19 Feb 2009 01:29:45 pm Post subject: |
|
|
There's this nice little bcall insertmem that'll insert the amount of memory somewhere you want. Or, you can use createAppVar (I can't remember the exact name of the ROM call) to create an appvar to store everything in.
As for getting your application to work, I'd recommend http://z80-heaven.wikidot.com/. There are a few tutorials under "flash application", including stuff about the app header, a simple flash application, and some nuances about programming a flash app vs. a regular program. It also has a tutorial that'll tell you how to create an appvar, and different things you can do with appvars.
I haven't really gotten around to putting up anything about multi-page apps yet, but in essence you need a jump table and you'd bcall to the routines on the other pages. There are also a few changes to the app header and a few other places you'd need to make.
Last edited by Guest on 19 Feb 2009 01:32:52 pm; edited 1 time in total |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 19 Feb 2009 02:02:11 pm Post subject: |
|
|
the only thing im using all that pages for is levels... lol
the maximum pages is 5... no?
edit: the multi-page-app page is empty...
Last edited by Guest on 19 Feb 2009 02:10:24 pm; edited 1 time in total |
|
Back to top |
|
|
calc84maniac
Elite
Joined: 22 Jan 2007 Posts: 770
|
Posted: 19 Feb 2009 02:29:21 pm Post subject: |
|
|
The maximum number of pages depends on how many your calculator has free. RealSound shows this quite well. |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 19 Feb 2009 02:38:10 pm Post subject: |
|
|
Yeah, I know. There are a few blank pages on that site (because i'm a lazy butt and also don't have a lot of free time).
You can have as many pages as you want (granted there's enough rom space). |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 19 Feb 2009 02:49:44 pm Post subject: |
|
|
if i understand correctly, the app is copied to $4000-$8000
but where did al previous data go? |
|
Back to top |
|
|
Galandros
Active Member
Joined: 29 Aug 2008 Posts: 565
|
Posted: 19 Feb 2009 03:04:56 pm Post subject: |
|
|
darkstone knight wrote: if i understand correctly, the app is copied to $4000-$8000
but where did al previous data go?
Well you have to change the current Flash page you are in.
From $4000 to $8000 you have the data in the first app page, then you need to swap using, with I think, port $06. Then in $4000 to $8000 you will have the other page.
michael vincent in his website had a text where I learned much of what I know of this.
I have some doubts about the operation in multi pages. Maybe others can help or you can try to see a source code of a multi page apps.
I know that you have to change a byte in the header to say how many pages you have, mind that you are in ROM so no SMC and validate correctly. For that you need to use .block/.fill in the assembler to fill the remaining app page data. I don't know either how it works. Have some idea but never tested seriously.
Last edited by Guest on 19 Feb 2009 03:06:32 pm; edited 1 time in total |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 19 Feb 2009 03:14:05 pm Post subject: |
|
|
Galandros wrote: Maybe others can help or you can try to see a source code of a multi page apps.
digitan!
does that mean you cannot write to $4000-$8000? then how do i update highscores? |
|
Back to top |
|
|
calc84maniac
Elite
Joined: 22 Jan 2007 Posts: 770
|
Posted: 19 Feb 2009 03:26:17 pm Post subject: |
|
|
darkstone knight wrote: Galandros wrote: Maybe others can help or you can try to see a source code of a multi page apps.
digitan!
does that mean you cannot write to $4000-$8000? then how do i update highscores?
That's where the aptly-named "app vars" come in. |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 19 Feb 2009 03:30:24 pm Post subject: |
|
|
i asume appvars work different than apps?
man, i thougth this was a 5-minute work... define pages using spasm, use a bcall to get 3k ram, load some pointers, and you'r ready to roll.. |
|
Back to top |
|
|
calc84maniac
Elite
Joined: 22 Jan 2007 Posts: 770
|
Posted: 19 Feb 2009 03:48:05 pm Post subject: |
|
|
Appvars are variables that can hold data, much like programs can. Most apps use these variables to store high scores and such. |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 19 Feb 2009 03:59:07 pm Post subject: |
|
|
sample code of using appvars? :biggrin:
i need code lol |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 19 Feb 2009 04:13:11 pm Post subject: |
|
|
yay :D
im just lazy >.>
*waits patiently for somebody that can tell me how multi-page-apps work
edit: i assume i need to unarchive it every time i start my program, and archive it on exit?
edit: and i can use the appvar to locate 3k worth of ram?
resizing it every time, duh..
Last edited by Guest on 19 Feb 2009 04:17:16 pm; edited 1 time in total |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 19 Feb 2009 06:07:45 pm Post subject: |
|
|
Or, if you know what size you want it to be to begin with, create it using the right size :)
I know how to create multi-page apps using latenite/brass, but i'm not familiar with spasm.
Last edited by Guest on 19 Feb 2009 06:08:07 pm; edited 1 time in total |
|
Back to top |
|
|
TheStorm
Calc Guru
Joined: 17 Apr 2007 Posts: 1233
|
Posted: 19 Feb 2009 06:22:09 pm Post subject: |
|
|
Don't forget about http://wikiti.brandonw.net/, there is a lot of good TI documentation there, plus some example code. |
|
Back to top |
|
|
FloppusMaximus
Advanced Member
Joined: 22 Aug 2008 Posts: 472
|
Posted: 19 Feb 2009 07:14:32 pm Post subject: |
|
|
Basic stuff about apps:
Apps are stored in FlashROM, starting at the beginning of a Flash page. (This is why all applications are multiples of 16384 bytes in size.) This means that the calculator doesn't need to "copy" your app anywhere to run it -- all it needs to do is to map the correct page to the $4000 memory bank (using port 6) and then jump to the start of your app.
Running in FlashROM does mean that you can't have SMC; you have to initialize all your variables by hand; and so forth.
A multi-page app consists, obviously, of multiple pages. Only one page, however, is mapped into the Z80 memory at a time. If you want to call a routine that's on a different page, or access data on a different page, you need to have some way of changing the memory mapping without crashing. There are many ways to deal with this problem; here are a few.
1. The way TI recommends and supports is to use B_CALLs. What you do is you create a table somewhere on the first page of your app, like so:
Code: _SomeRoutine .equ $ - $4000; SomeRoutine is located on the first page of your app
.dw SomeRoutine
.db 0
_AnotherRoutine .equ $ - $4000; AnotherRoutine is located on the second page of your app
.dw AnotherRoutine
.db 1
You can then call SomeRoutine from anywhere in your app, using "B_CALL _SomeRoutine" (or "B_CALL SomeRoutine", if you're using ZMASM.) Note that there's a big difference between "B_CALL _SomeRoutine \ ret" and "B_JUMP _SomeRoutine".
Using B_CALLs can be quite convenient, as it takes up very little space. Most of the time, though, what's stored on the other pages of your app is data, not code, so I don't find B_CALLs very useful in practice.
2. The easiest way to read data from another page of your app is to use the FlashToRAM routine. For instance, if you had a 768-byte bitmap stored on the second page of your app, you could do
Code: ld hl,MyBitmap
ld de,plotSScreen
ld bc,768
in a,(6); get the current page #
dec a
B_CALL _FlashToRAM
to copy the bitmap to plotSScreen.
3. If you want to read data from another page of your app by hand, you can copy some code into RAM. For example:
Code: ld hl,MyRAMCode
ld de,ramCode
ld bc,MyRAMCodeSize
ldir
jp ramCode
...
MyRAMCode:
in a,(6)
dec a
out (6),a
ld hl,MyBitmap
ld de,plotSScreen
ld bc,768
ldir
inc a
out (6),a
ret
MyRAMCodeSize .equ $ - MyRAMCode
This is the method that you'll generally want to use if you have a lot of compressed data; you'd copy the decompression code into RAM, and use it to decompress data that's stored whereever. (My current project, Flashbook, provides a good example of how to do this, if you're interested. So, I would guess, does RealSound, though I haven't read its code myself.)
For writing RAM code snippets like this, incidentally, I highly recommend using an assembler that supports RORG (such as tpasm.)
As far as memory goes: If you can by any means avoid dynamic allocation, you should, as it's a real pain and tends to cause a lot of bugs. If not...
There's plenty about AppVars and other RAM variables in the SDK.
You can use the FPS, so long as you allocate data in increments of 9 bytes:
Code: ld hl,AmountOfRAMINeed; where AmountOfRAMINeed is a multiple of 9
B_CALL _EnoughMem
jr c,MemoryError
ld de,AmountOfRAMINeed
ld hl,(FPS)
ld (iMathPtr1),hl
add hl,de
ld (FPS),hl
...at which point iMathPtr1 points to the start of your memory block. (It's a good idea to use the imathptrs, as they will be updated automatically if you need to do any variable manipulation, like creating high score files and stuff like that.)
If you don't need to do any variable manipulation, or any complicated math, you can just use the free space between FPS and OPS.
This is, of course, just a sampling of what there is to say about Flash Apps. I'll be happy to answer any specific questions.
Last edited by Guest on 19 Feb 2009 07:15:41 pm; edited 1 time in total |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 20 Feb 2009 07:24:09 am Post subject: |
|
|
well, that answers most of my questions, thanks :)
@wikiguru
the idea was to use the appvar as data storage during the program ( i need 1.5k for 64*25 maps)
i might be able to do that without using bcall(_ junk... |
|
Back to top |
|
|
TheStorm
Calc Guru
Joined: 17 Apr 2007 Posts: 1233
|
Posted: 20 Feb 2009 08:10:32 am Post subject: |
|
|
darkstone knight wrote: well, that answers most of my questions, thanks :)
@wikiguru
the idea was to use the appvar as data storage during the program ( i need 1.5k for 64*25 maps)
i might be able to do that without using bcall(_ junk...
Um, you can't even create the appvar without using bcall's so I'm not sure what you are talking about there. And the fact that bcalls are you friends, they let not rewrite the entire os for simple apps. |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 20 Feb 2009 09:07:46 am Post subject: |
|
|
Yeah, it's better not to create a vat entry on your own... strange things can happen, and since you know the size of appvar you'd need, you wouldn't need to do anything with changing the memory. It is possible to scan the vat yourself, but that's also not too fun (especially since there are all sorts of tokens in the vat of varying sizes), and the bcall is oh so convenient. |
|
Back to top |
|
|
|