0 Members and 1 Guest are viewing this topic.
Delay: dec hl ld a, h or l jr nz, delay ret
1. I know my house might get bombed for this, but honestly, the only way I can see to do this would be to check out how Axe does it. Axe draws perfect circles very quickly and if I needed a circle routine, I would just copy axe's.
2. This one has actually been done for you, bcall(_DrawRectBorderClear) draws a rectangle with a white inner section. (Page 142 if your browser doesn't redirect you)
3. If you mean just draw text, then bcall(_vPutS) is your routine. But, if you mean draw text within a certain boundary area, bcall(_SFont_Len) will tell you how long an individual letter is. From there, you can draw the letters 1 by 1 with bcall(_vPutMap) and start a new line whenever you run out of space. (bcall(_SFont_Len) is on page 47 of that pdf I linked above)
4. There are so many sprite rendering routines, there's no need to make a new one. Here is a page for 8-bit wide sprites and here is a page for 16-bit wide sprites. However, if you want just a single routine to do all of your sprites no matter how big they are, this is your routine. Of course, picking one of the smaller ones would be faster than this though.
As for the delays, your best bet is to make a single delay routine and call it. In all honesty this routine right here is probably all you need:Code: [Select]Delay: dec hl ld a, h or l jr nz, delay ret
Yeah. I think I can handle that. How many 'nop' or 'halt' cycles would equal 1 second, in fast mode?
;hl = milliseconds of delaymilliDelay: ld b, 174 ;7innerLoop: ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 djnz innerLoop ;13*173+8 ;2257 dec hl ;6 ld a, h ;4 or l ;4 jr nz, milliDelay ;13 ret ;15,515
Quote from: ACagliano on October 10, 2011, 01:30:43 pmYeah. I think I can handle that. How many 'nop' or 'halt' cycles would equal 1 second, in fast mode?For nops, you need whole heck of a lot. Each nop takes 4 t-states. And you figure the median calculator is running at 15,500,000 t-states per second so... 3.7 million nops.If you want to use instructions to slow down your program, here's a routine you can use:Code: [Select];hl = milliseconds of delaymilliDelay: ld b, 174 ;7innerLoop: ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 djnz innerLoop ;13*173+8 ;2257 dec hl ;6 ld a, h ;4 or l ;4 jr nz, milliDelay ;13 ret ;15,515Halts work entirely different though. Halts wait for an interrupt and the interrupts run at a constant speed. That speed is 118 Hz on an 83+ and 107.79 Hz on everything else. But since you said you're running in fast mode, clearly you are not on an 83+ so you would need 108 halts to wait for one second.(I said "median" calculator up above because calculators run anywhere from 14.5 MHz to 17.0 MHz in fast mode)
in a,($2E) ;initialize faster processingpush afld a,0out ($2E),acall Start ;jump to main program. the main program will return here when 'ret' is calledpop afout ($2E),aret
ld a, 3 out ($20), a
Multiply hl by 1000 to turn it into milliseconds. If you don't need all of the precision, leftshifting hl by 10 is approximately the same.
Can I use a for this, rather than hl?
;a = milliseconds of delaymilliDelay: ld b, 174 ;7 <-Increase this for larger delay increments.innerLoop: ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 djnz innerLoop ;13*173+8 ;2257 dec a ;4 nop nop ;Left here to keep similar timing. jr nz, milliDelay ;13 ret ;15,515
;a = high byte of milliseconds of delay ld l, 0 ;7 ld h, a ;4milliDelay: ld b, 174 ;7innerLoop: ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 djnz innerLoop ;13*173+8 ;2257 dec hl ;6 ld a, h ;4 or l ;4 jr nz, milliDelay ;13 ret ;15,515
ld b,107 halt djnz $-1 dec a jr nz,$-6 ret
So if you want to delay for approximately 'a' seconds you can try this:Code: [Select] ld b,107 halt djnz $-1 dec a jr nz,$-6 retDoes this help?
Quote from: Xeda112358 on October 11, 2011, 08:24:12 pmSo if you want to delay for approximately 'a' seconds you can try this:Code: [Select] ld b,107 halt djnz $-1 dec a jr nz,$-6 retDoes this help?What does $-6 mean? $-1?
delayLoop: ld b,107haltLoop: halt djnz haltLoop dec a jr nz,delayLoop ret