Ok, so for a game I've been making a rudimentary scripting language for making cutscenes.
http://eeems.pastebin.com/2zZJPQJV is the code for the parser and I'm running this script through it:
Code:
intro_scene:
   Pclearscreen
   Psprite(8,8,BlackMage,P8x16)
   Pupdatescreen
   Pwait(1)
   Prect(8,8,16,16,0)
   Psprite(6,8,BlackMage,P8x16)
   Pupdatescreen
   Ptext(0,0,"This is a cutscene")
   Pupdatescreen
   Ppause
   Pend
For some reason it's erroring for no reason, I believe that there might be a problem with how I setup one of the command routines, but I'm not sure. In the parser hl is the current position in the script and during the check a contains what the current token is.
If you want to know what any of the routines I use are just let me know, but they shouldn't cause any problems unless somehow they change HL, which I'm pretty sure I've protected against.
Any ideas?
Error: and without that second Psprite() it works

Code:
_       ld a,d
        push hl
                push bc
                        call putSprite8xb
                pop bc
        pop hl
        inc hl
        ret
_       push hl
                push ix
                pop hl
                call putmaskedSprite
        pop hl
        ret
Why does one get an inc hl and the other doesn't? Also, for some reason your command choice macro assumes weird flag states exiting your routines to indicate errors (or lack thereof), which I don't see you guaranteeing at all.
Oh, well the second one hasn't been called, but that was trying to figure out if it was exiting in the wrong position.
I forgot about the flags x.x I need to add a push af / pop af around the call
it isn't for errors, it's for saving time on the checks and jumping back to the start
I'll check to see if that is the problem

EDIT: thanks, that was it!
Woot, glad I could help. Please continue to use this thread to ask for help on this project, and hopefully make a project thread about it soon.
ok, this routine when I run it with this script
Code:
Psprite(8,16,BlackMage,P8x16m)
it somehow goes to the game engine but quits like it's still in the parser...

here is the code in question

Code:
parse_sprite:
   inc hl
   ld d,(hl)   ;x
   inc hl
   ld e,(hl)   ;y
   inc hl
   push de
      ld e,(hl)
      inc hl
      ld d,(hl)
      push de
      pop ix
   pop de ;pointer
   inc hl
   ld a,(hl)   ;type
   cp 2
      jr z,++++_   ;8*16 masked
   cp 1
      jr z,_   ;8*16
   ld b,8   ;8*8
   jr ++_
_   ld b,16
_   ld a,d
   push hl
      push bc
         call putSprite8xb
      pop bc
   pop hl
   ret
_   push hl
      push ix
      pop hl
      call putmaskedSprite
   pop hl
   ret
it specifically is calling the second part, where call putmaskedSprite is
And this bug doesn't happen when you don't include the sprites in the cutscene?
That bug doesn't happen when I don't use P8*16m and instead one of the other two formats.

EDIT: error was actually one too many + signs
ok, not a question about the scripting part, but I was wondering if anybody could walk me through storing data in an appvar and recalling that data
Creating an AppVar:


Code:
   ld hl,AppVarName
   rst 20h
   bcall(_chkfindsym)
   jr nc,AlreadyExists
   ld hl,appvarsize
   bcall(_createappvar)
   ret
AppVarName:
   .db $15,"MYAVAR"


Accessing:

Code:
ld hl,AppVarName
rst 20h
bcall(_chkfindsym)
jr c,DoesNotExist
ld hl,offsetthatwewant+2 ;+2 is for the size word
add hl,de
;now hl is offsetthatwewant bytes into the data
Thanks Kerm!

EDIT: Erm, I noticed you said something about size bytes, what are they for? I'm guessing pretty much, how would I save to an appvar correctly
Eeems wrote:
Thanks Kerm!

EDIT: Erm, I noticed you said something about size bytes, what are they for? I'm guessing pretty much, how would I save to an appvar correctly
Well, you have to define the size of the appvar. Smile I'm hoping you're going to try to maintain your sanity by not trying to resize appvars on the fly with your first exploration of using them. When you call _chkfindsym, (de) and (de+1) are the LSB and MSB respectively of the size of the appvar.
Well the size is going to be constant, and I'm going to use BlackMageStats-SaveEnd to define how big that actually is. For saving over data in the appvar would I do
Code:
  inc de
  inc de
  ld bc,BlackMageStats-SaveEnd
  ld hl,BlackMageStats
  ldir
or would that be an issue?
Assuming that that code goes after the bcall(_chkfindsym), that would work quite well.
ok, for some reason, this code:
Code:
engine_save:
   call tobackbuff
   homeup
   ld hl,save_appvar_name
   rst 20h
   bcall(_chkfindsym)
      jr nc,_   ;if it exists jump to saving
   ld hl,BlackMageStats-SaveEnd
   bcall(_createappvar)
_   inc de
   inc de
   ld hl,BlackMageStats
   ld bc,BlackMageStats-SaveEnd
   ldir
   
   wrappedtext(saved_text)
   lcdupdate
   call Pausekey
   call frombackbuff
   jp engine_return
causes this:

I know it's the ldir that causes it, because commenting it out fixes things
Errr, I'm pretty sure you made the rookie mistake of "BlackMageStats-SaveEnd " instead of "SaveEnd-BlackMageStats"? Smile
Hmm, and in my head I had even thought to make sure I had the right order...x.x
Eeems wrote:
Hmm, and in my head I had even thought to make sure I had the right order...x.x
Don't worry, I do that more often than I'd like to admit. Smile Does it work now?
It works great Smile 32 bytes so far in the appvar Razz

EDIT: oh yeah, and to protect against the appvar being archived on load/save?
Eeems wrote:
It works great Smile 32 bytes so far in the appvar Razz

EDIT: oh yeah, and to protect against the appvar being archived on load/save?
Check register b after ChkFindSym. If it's non-zero, then you need to unarchive the AppVar.
Eeems wrote:
For some reason it's erroring for no reason
Wait... What?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement