Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: Jerros on May 24, 2010, 10:52:38 am
-
I've finally created an App, but when I run it, all sprites/text in the screen is messed up.
Everything does work, it reacts correctly to buttons pressed, but whenever I use a sprite or do something like :
LD HL, $0006
LD (CurRow), HL
LD HL, Sometext
b_call _PutS
the screen fills with random stuff.
The program doesn't crash, I can still switch between menus by pressing the correct buttons (I made the priogram, so I can navigate blind in it), but like said, text shown as above and sprites dont work.
The programm worked fine before being turned into an App, and most sprites seem to show in the upper left corner of the screen, instead of twhere they're supposed to be.
I've used AppDev to compile the .z80 into an app.
Has anyone encountered the same problem?
How to fix this?
As said befire, when I normally compile it, it works perfectly fine.
I'm exeeding the 8kB limit though, so that's why I'm turining it into an App.
If I need to include more info, just ask and I'll post it.
Some random info that might/might not be related to the problem:
My header:
#INCLUDE "DWEDIT.INC"
#IFDEF APP
.org $4000
#IFNDEF NOAPPHEADER
;This is the application header definition area required for all apps.
.db 080h,0Fh ;Field: Program length
.db 00h,00h,00h,00h ;Length=0 (N/A for unsigned apps)
.db 080h,012h ;Field: Program type
#ifdef TI73
.db 01h, 02h ;type=Shareware, TI-73
#else
.db 01h,04h ;Type= Shareware, TI-83Plus
#endif
.db 080h,021h ;Field: App ID
.db 01h ;Id = 1
.db 080h,031h ;Field: App Build
.db 01h ;Build = 1
.db 080h,048h ;Field: App Name
.db "CalcHero"
.db 080h,081h ;Field: App Pages
.db 1
.db 080h,090h ;No default splash screen
.db 03h,026h ,09h,04h, 04h,06fh,01bh,80h ;Field: Date stamp- 5/12/1999
.db 02h,0dh,040h ;Dummy encrypted TI date stamp signature
.db 0a1h ,06bh ,099h ,0f6h ,059h ,0bch ,067h
.db 0f5h ,085h ,09ch ,09h ,06ch ,0fh ,0b4h ,03h ,09bh ,0c9h
.db 03h ,032h ,02ch ,0e0h ,03h ,020h ,0e3h ,02ch ,0f4h ,02dh
.db 073h ,0b4h ,027h ,0c4h ,0a0h ,072h ,054h ,0b9h ,0eah ,07ch
.db 03bh ,0aah ,016h ,0f6h ,077h ,083h ,07ah ,0eeh ,01ah ,0d4h
.db 042h ,04ch ,06bh ,08bh ,013h ,01fh ,0bbh ,093h ,08bh ,0fch
.db 019h ,01ch ,03ch ,0ech ,04dh ,0e5h ,075h
.db 80h,7Fh ;Field: Program Image length
.db 0,0,0,0 ;Length=0, N/A
.db 0,0,0,0 ;Reserved
.db 0,0,0,0 ;Reserved
.db 0,0,0,0 ;Reserved
.db 0,0,0,0 ;Reserved
#ENDIF
#ENDIF
Oh, and I use this to put a sprite on the screen:
LD A, 46 ; Random number
LD (ypos), A
LD A, 27 ; another Random number
LD (xpos), A
LD B, 18 ; Length of sprite in Y direction
LD DE, (ypos)
LD IX, Sprite ; Label of the sprite
CALL Showsprite
Showsprite: ; Show Sprite (XOR)
CALL ClipSprXOR
b_call _GrBufCpy
ret
ClipSprXOR: ; Show Sprite XOR
LD A, %11111111
LD (clip_mask), A
LD A, E
OR A
JP M, ClipTop
SUB 64
RET NC
NEG
CP B
JR NC, VertClipDone
LD B, A
JR VertClipDone
ClipTop:
LD A, B
NEG
SUB E
RET NC
PUSH AF
ADD A, B
LD E, 0
LD B, E
LD C, A
ADD IX, BC
POP AF
NEG
LD B, A
VertClipDone:
LD C, 0
LD A, D
CP -7
JR NC, ClipLeft
CP 96
RET NC
CP 89
JR C, HorizClipDone
ClipRight:
AND 7
LD C, A
LD A, %11111111
FindRightMask:
ADD A, A
DEC C
JR NZ, FindRightMask
LD (clip_mask), A
LD A, D
JR HorizClipDone
ClipLeft:
AND 7
LD C, A
LD A, %11111111
FindLeftMask:
ADD A, A
DEC C
JR NZ, FindLeftMask
CPL
LD (clip_mask), A
LD A, D
ADD A, 96
LD C, 12
HorizClipDone:
LD H, 0
LD D, H
LD L, E
ADD HL, HL
ADD HL, DE
ADD HL, HL
ADD HL, HL
LD E, A
SRL E
SRL E
SRL E
ADD HL, DE
LD DE, PlotSScreen
ADD HL, DE
LD D, 0
LD E, C
SBC HL, DE
AND 7
JR Z, _Aligned
LD C, A
LD DE, 11
_RowLoop:
PUSH BC
LD B, C
LD A, (clip_mask)
AND (IX)
LD C, 0
_ShiftLoop:
SRL A
RR C
DJNZ _ShiftLoop
XOR (HL)
LD (HL), A
INC HL
LD A, C
XOR (HL)
LD (HL), A
ADD HL, DE
INC IX
POP BC
DJNZ _RowLoop
RET
_Aligned:
LD DE, 12
_PutLoop:
LD A, (IX)
XOR (HL)
LD (HL), A
INC IX
ADD HL, DE
DJNZ _PutLoop
RET
-
When you do a Bcall, the address you are giving on your app page will be pointing to random OS data instead. What most APP developers do is write their own _PutS routine like this:
app_PutS:
ld a,(hl)
inc hl
or a
ret z
b_call _PutC
jr app_PutS
Hope this helps!
-
When you do a Bcall, the address you are giving on your app page will be pointing to random OS data instead. What most APP developers do is write their own _PutS routine like this:
LĂttle more info please, what it all does? :O
I'm a very newby programmer, so some more concrete info would be appreciated.
I do understany WHY the lot is messed up, thanx, though I still dont understand how to fix it.
And wha tyou said about the B_calls, does that count for ALL B_calls?
Because most, like b_call _RunIndicOff and b_call _GrBufClr seem to work fine...
Thanks anyway.
-
Well, your app page is mapped in at addresses $4000-$7fff. When you do a Bcall, the OS page with the routine is temporarily put there, so the data pointed to by HL will no longer be your text. That's why it works if you read your text data and display each character manually, since the OS will not be trying to read data from your APP.
-
Well, your app page is mapped in at addresses $4000-$7fff. When you do a Bcall, the OS page with the routine is temporarily put there, so the data pointed to by HL will no longer be your text. That's why it works if you read your text data and display each character manually, since the OS will not be trying to read data from your APP.
I start to get it...
Though I still don't understand how your posted code can help.
What do I do in order to show sprited/text the right way?
I don't know what to do with the code you gave me, sorry :C
-
I start to get it...
Though I still don't understand how your posted code can help.
What do I do in order to show sprited/text the right way?
I don't know what to do with the code you gave me, sorry :C
Instead of using:
bcall _PutS
use:
call app_PutS
and include the calcmaniac84 routine in the source code, of course.
-
Instead of using:
bcall _PutS
use:
call app_PutS
and include the calcmaniac84 routine in the source code, of course.
I'll try, thanks alot.
Oh, where can I find that source code of calcmaniac?
Been googling without result so far...
Meh, I'll keep searching.
-
Instead of using:
bcall _PutS
use:
call app_PutS
and include the calcmaniac84 routine in the source code, of course.
I'll try, thanks alot.
Oh, where can I find that source code of calcmaniac?
Been googling without result so far...
Meh, I'll keep searching.
Some name it safePutS.
This is the routine that calcmaniac found in this topic:
app_PutS:
ld a,(hl)
inc hl
or a
ret z
b_call _PutC
jr app_PutS
-
Replaced all the "b_call_PutS" with "call app_PutS" and included the small routine, but it's still messed up.
It does show the text now, though its in large font, and no where near where I want it.
Also, I can't applie it to sprites :/
I'm probably doing something wrong, but what's the normal way to display sprites/small text in an app where I want when I want?
Works when I use TASM to assemble and run it, but in an app its all still random junk on the screen, QQ.
-
I think you're thinking of "VPutS" instead of "PutS". You also change "PutC" to "VPutMap" and instead of using CurCol and CurRow you use PenCol and PenRow. I'm surprised this worked in small font before as a non-app, that's strange...
The sprites not working now but working before sounds like you might still have some self modifying code. Either that, or you're using some other bcall that can't be executed in the $4000 address.
-
Replaced all the "b_call_PutS" with "call app_PutS" and included the small routine, but it's still messed up.
It does show the text now, though its in large font, and no where near where I want it.
Also, I can't applie it to sprites :/
I'm probably doing something wrong, but what's the normal way to display sprites/small text in an app where I want when I want?
Works when I use TASM to assemble and run it, but in an app its all still random junk on the screen, QQ.
For using small font there is a flag you need to change. (see asmin28days tutorial in the part about text display, I think)
There is other flag to write only to the buffer and not to the screen, so you copy the buffer to screen whenever you want.
For sprites a normal routine works, are you giving the right inputs for it?
If you have some bugs on the APPS, it can happen to show strange symbols in all the screen upon exit.
-
Hmm...
It's annoying that my programm is nearly completed, but that things aren't workigng now because it's an App...
I shall try your suggestions, but otherwise I might need to PM my whole program (its VERY easy, since I'm a newby programmer) to someone, I bet you can see whats wrong in a quick glance.
I'm not asking anyone to fully "scan" my programm, but if someone wants to take quick peek to see wahts worng, tell me and I PM you the script.
For now I'll just try then things you've suggested.
Thanks ALOt for your help people!
-
I don't know how to fix the sprite problem, but try this for your string:
LD HL, $0006
LD (CurRow), HL
LD HL, Sometext
LD DE, OP1
LD BC, ______ ; _____ is the length of your string in characters, INCLUDING the zero at the end
LDIR
LD HL, OP1
b_call _PutS
I really have no idea what this will do for your app, but it fixed all my string problems for my app
-
LD BC, ______ ; _____ is the length of your string in characters, INCLUDING the zero at the end
I'll try, but you mean I load the number in BC that contains the number of characters +1?
So "Hello World!" would be
LD BC, 13
?
I'll try and see, as for the sprites it might be a self-modifieing code, like Quigibo said.
Unfortunately I can't touch the PC with the programming tools right now, but I'll try all suggestions later.
Thanks.
-
LD BC, ______ ; _____ is the length of your string in characters, INCLUDING the zero at the end
I'll try, but you mean I load the number in BC that contains the number of characters +1?
So "Hello World!" would be
LD BC, 13
?
Yes, that's correct.