@@ -907,7 +907,7 @@ gfx_Rectangle_NoClip:
907907 ; de = ti.lcdWidth
908908 sbc hl , de ; hl = &buf[y+height-1][x]
909909 pop bc ; bc = width
910- jp _HorizLine_NoClip_Draw ; draw bottom horizontal line
910+ jr _HorizLine_NoClip_Draw ; draw bottom horizontal line
911911
912912;-------------------------------------------------------------------------------
913913gfx_HorizLine:
@@ -1233,7 +1233,7 @@ gfx_FillEllipse:
12331233 ld hl , _ellipse_ret
12341234 ld (_ellipse_loop_draw_1) , hl
12351235 jr _Ellipse
1236-
1236+
12371237;-------------------------------------------------------------------------------
12381238gfx_Ellipse_NoClip:
12391239 ld hl , _SetPixel_NoClip_NoWait
@@ -1281,7 +1281,7 @@ _Ellipse:
12811281 add ix , sp
12821282 lea hl , ix - 42
12831283 ld sp , hl
1284-
1284+
12851285; First, setup all the variables
12861286 ld a , (ix + 12 )
12871287 or a , a
@@ -1366,7 +1366,7 @@ _Ellipse:
13661366 ld de , (ix - el_y)
13671367 call _MultiplyHLDE
13681368 ld (ix - el_comp_b) , hl
1369-
1369+
13701370 wait_quick
13711371
13721372.main_loop1:
@@ -2512,9 +2512,7 @@ gfx_GetClipRegion:
25122512 ld hl , 3
25132513 add hl , sp
25142514 ld iy , (hl)
2515- dec iy
2516- dec iy
2517- dec iy
2515+ lea iy , iy - 3
25182516 call _ClipRegion ; get the clipping region
25192517 sbc a , a ; return false if offscreen (0)
25202518 inc a
@@ -2899,15 +2897,15 @@ gfx_GetSprite:
28992897 sbc a , a
29002898 inc a
29012899 ld b , a ; the amount to add to get to the next line
2902- ld (.offset) , bc
2900+ push bc
2901+ pop iy
29032902 ld a , (de)
29042903 inc de
29052904. loop :
29062905 ld bc , 0
29072906.amount := $ - 3
29082907 ldir ; copy the data into the struct data
2909- ld bc , 0
2910- .offset := $ - 3
2908+ lea bc , iy ; (.offset)
29112909 add hl , bc
29122910 dec a
29132911 jr nz , . loop
@@ -3219,20 +3217,7 @@ _Tilemap:
32193217 ld (ix - 3 ) , h
32203218 sbc hl , bc
32213219 ld (ix - 12 ) , hl
3222- jp .yloop
3223-
3224- .xres := $ + 3
3225- . loop :
3226- ld (ix - 1 ) , 0
3227- ld hl , 0
3228- .xoffset := $ - 3
3229- ld (ix - 7 ) , hl
3230- ld l , (iy + t_width)
3231- ld h , (ix - 4 )
3232- mlt hl
3233- ld (.ynext) , hl
3234- xor a , a
3235- jr .xloop
3220+ jr .yloop
32363221
32373222.xloopinner:
32383223 or a , a
@@ -3288,7 +3273,20 @@ _Tilemap:
32883273.yloop:
32893274 ld a , (iy + t_draw_height)
32903275 cp a , (ix - 3 )
3291- jp nz , . loop
3276+ jr z , .finish_loop
3277+ .xres := $ + 3
3278+ ; .loop:
3279+ ld (ix - 1 ) , 0
3280+ ld hl , 0
3281+ .xoffset := $ - 3
3282+ ld (ix - 7 ) , hl
3283+ ld l , (iy + t_width)
3284+ ld h , (ix - 4 )
3285+ mlt hl
3286+ ld (.ynext) , hl
3287+ xor a , a
3288+ jr .xloop
3289+ .finish_loop:
32923290 ld sp , ix
32933291 pop ix
32943292 ret
@@ -3855,8 +3853,7 @@ gfx_GetStringWidth:
38553853; Returns:
38563854; Width of string in pixels
38573855 pop de
3858- pop hl
3859- push hl ; hl -> string
3856+ ex ( sp ) , hl ; hl -> string
38603857 push de
38613858 ld de , 0
38623859. loop :
@@ -3880,10 +3877,11 @@ gfx_GetCharWidth:
38803877; arg0 : Character
38813878; Returns:
38823879; Width of character in pixels
3883- ld iy , 0
3884- lea de , iy
3885- add iy , sp
3886- ld a , (iy + 3 ) ; a = character
3880+ ld hl , 3
3881+ add hl , sp
3882+ ld a , (hl) ; a = character
3883+ sbc hl , hl
3884+ ex de , hl
38873885_GetCharWidth:
38883886 sbc hl , hl
38893887 ld l , a
@@ -3996,8 +3994,7 @@ gfx_SetFontData:
39963994; Returns:
39973995; Pointer to previous font data
39983996 pop de
3999- pop hl
4000- push hl ; hl -> custom font data
3997+ ex ( sp ) , hl ; hl -> custom font data
40013998 push de
40023999 add hl , de
40034000 or a , a
@@ -4048,8 +4045,7 @@ gfx_SetFontSpacing:
40484045; Returns:
40494046; None
40504047 pop de
4051- pop hl
4052- push hl ; hl -> custom font width
4048+ ex ( sp ) , hl ; hl -> custom font width
40534049 push de
40544050 add hl , de
40554051 or a , a
@@ -4070,10 +4066,9 @@ gfx_SetMonospaceFont:
40704066 pop hl
40714067 pop de
40724068 push de
4073- push hl
40744069 ld a , e ; a = width
40754070 ld (_TextFixedWidth) , a ; store the value of the monospace width
4076- ret
4071+ jp (hl)
40774072
40784073;-------------------------------------------------------------------------------
40794074gfx_FillTriangle_NoClip:
@@ -4145,7 +4140,7 @@ _FillTriangle:
41454140 ld hl , (ix + 9 )
41464141 or a , a
41474142 sbc hl , de
4148- jp nz , .notfl at
4143+ jr nz , .notfl at
41494144 ld bc , (ix + 6 ) ; x0
41504145 ld (ix - 6 ) , bc ; a = x0
41514146 ld (ix - 3 ) , bc ; b = x0;
@@ -4196,29 +4191,6 @@ _FillTriangle:
41964191 jp p , .cmp30
41974192 jp pe , .cmp31
41984193 jr .cmp32
4199- .cmp30:
4200- jp po , .cmp31
4201- .cmp32:
4202- ld bc , (ix + 18 )
4203- ld (ix - 6 ) , bc
4204- .cmp31:
4205- ld de , (ix - 3 )
4206- ld hl , (ix - 6 )
4207- or a , a
4208- sbc hl , de
4209- inc hl
4210- push hl
4211- ld bc , (ix + 9 )
4212- push bc
4213- push de
4214- call 0 ; horizline(a, y0, b-a+1);
4215- .line0 := $ - 3
4216- pop bc
4217- pop bc
4218- pop bc
4219- ld sp , ix
4220- pop ix
4221- ret ; return;
42224194.notfl at :
42234195 ld bc , (ix + 6 ) ; x0
42244196 ld hl , (ix + 12 )
@@ -4251,14 +4223,34 @@ _FillTriangle:
42514223 jr nz , .elselast ; if (y1 == y2) { last = y1; }
42524224 ld (ix - 24 ) , bc
42534225 jr .sublast
4226+ .cmp30:
4227+ jp po , .cmp31
4228+ .cmp32:
4229+ ld bc , (ix + 18 )
4230+ ld (ix - 6 ) , bc
4231+ .cmp31:
4232+ ld de , (ix - 3 )
4233+ ld hl , (ix - 6 )
4234+ or a , a
4235+ sbc hl , de
4236+ inc hl
4237+ push hl
4238+ ld bc , (ix + 9 )
4239+ push bc
4240+ push de
4241+ call 0 ; horizline(a, y0, b-a+1);
4242+ .line0 := $ - 3
4243+ ld sp , ix
4244+ pop ix
4245+ ret ; return;
42544246.elselast:
42554247 ld bc , (ix + 15 ) ; else { last = y1-1; }
42564248 dec bc
42574249 ld (ix - 24 ) , bc
42584250.sublast:
42594251 ld bc , (ix + 9 )
42604252 ld (ix - 12 ) , bc ; for (y = y0; y <= last; y++)
4261- jp .firstloopstart
4253+ jr .firstloopstart
42624254.firstloop:
42634255 ld hl , (ix - 15 )
42644256 ld bc , (ix - 33 )
@@ -4335,7 +4327,7 @@ _FillTriangle:
43354327 ld de , (ix - 21 )
43364328 call _MultiplyHLDE ; sb = dx02 * (y - y0);
43374329 ld (ix - 18 ) , hl
4338- jp .secondloopstart ; for(; y <= y2; y++)
4330+ jr .secondloopstart ; for(; y <= y2; y++)
43394331.secondloop:
43404332 ld hl , (ix - 15 )
43414333 ld bc , (ix - 39 )
@@ -4836,8 +4828,7 @@ gfx_ScaleSprite:
48364828 pop de ; de->tgt_data
48374829 ld iy , 0
48384830 ld iyl , a
4839- ld a , c ; du = bc:iyl
4840- ld (du) , a ; ixl = target_height
4831+ ld ixh , c ; (.du) = bc:iyl, ixl = target_height
48414832
48424833; b = out_loop_times
48434834; de = target buffer adress
@@ -4847,9 +4838,9 @@ ScaleWidth := $+2
48474838 ld iyh , 0
48484839 xor a , a
48494840 ld b , a
4850- ld c , 0
4851- du := $ - 1
4852- . loop : ldi
4841+ ld c , ixh ; (.du)
4842+ . loop :
4843+ ldi
48534844 add a , iyl
48544845 adc hl , bc ; xu += du
48554846 inc bc ; bc:iyl is du
@@ -6409,6 +6400,7 @@ _Maximum:
64096400; Oututs:
64106401; HL=max number
64116402 or a , a
6403+ .no_carry:
64126404 sbc hl , de
64136405 add hl , de
64146406 jp p , .skip
@@ -6427,6 +6419,7 @@ _Minimum:
64276419; Oututs:
64286420; HL=min number
64296421 or a , a
6422+ .no_carry:
64306423 sbc hl , de
64316424 ex de , hl
64326425 jp p , .skip
@@ -6464,7 +6457,7 @@ smcWord _XMax
64646457smcWord _YMin
64656458.YMin := $ - 3
64666459 ld de , (iy + 6 )
6467- call _Maximum
6460+ call _Maximum.no_carry
64686461 ld (iy + 6 ) , hl
64696462 ld hl , ti.lcdHeight
64706463smcWord _YMax
@@ -6733,7 +6726,7 @@ _DefaultCharSpacing:
67336726 db 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8
67346727
67356728_DefaultTextData:
6736- db $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 ;
6729+ db $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 ; 0
67376730 db $ 7E , $ 81 , $ A5 , $ 81 , $ BD , $ BD , $ 81 , $ 7E ; ☺
67386731 db $ 7E , $ FF , $ DB , $ FF , $ C3 , $ C3 , $ FF , $ 7E ; ☻
67396732 db $ 6C , $ FE , $ FE , $ FE , $ 7C , $ 38 , $ 10 , $ 00 ; ♥
@@ -6765,7 +6758,7 @@ _DefaultTextData:
67656758 db $ 00 , $ 24 , $ 66 , $ FF , $ 66 , $ 24 , $ 00 , $ 00 ; ↔
67666759 db $ 00 , $ 18 , $ 3C , $ 7E , $ FF , $ FF , $ 00 , $ 00 ; ▲
67676760 db $ 00 , $ FF , $ FF , $ 7E , $ 3C , $ 18 , $ 00 , $ 00 ; ▼
6768- db $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 ;
6761+ db $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 ; _
67696762 db $ C0 , $ C0 , $ C0 , $ C0 , $ C0 , $ 00 , $ C0 , $ 00 ; !
67706763 db $ D8 , $ D8 , $ D8 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 ; "
67716764 db $ 6C , $ 6C , $ FE , $ 6C , $ FE , $ 6C , $ 6C , $ 00 ; #
@@ -6860,7 +6853,7 @@ _DefaultTextData:
68606853 db $ C0 , $ C0 , $ C0 , $ 00 , $ C0 , $ C0 , $ C0 , $ 00 ; |
68616854 db $ E0 , $ 30 , $ 30 , $ 1C , $ 30 , $ 30 , $ E0 , $ 00 ; }
68626855 db $ 76 , $ DC , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 , $ 00 ; ~
6863- db $ 00 , $ 10 , $ 38 , $ 6C , $ C6 , $ C6 , $ FE , $ 00 ; △
6856+ db $ 00 , $ 10 , $ 38 , $ 6C , $ C6 , $ C6 , $ FE , $ 00 ; Δ
68646857
68656858_LcdTiming:
68666859; db 14 shl 2 ; PPL shl 2
0 commit comments