• R/O
  • SSH
  • HTTPS

oricsdk: Commit


Commit MetaInfo

Revision1712 (tree)
Time2023-10-01 22:03:19
Authordbug

Log Message

Replaced the manual kerning by a table of character pairs and some basic lookup code

Change Summary

Incremental Difference

--- users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/common.h (revision 1711)
+++ users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/common.h (revision 1712)
@@ -100,8 +100,6 @@
100100
101101
102102 // game_text
103-extern char gTextLowerCaseAlphabet[];
104-
105103 extern char gDescriptionTeenagerRoom[];
106104 extern char gDescriptionDarkTunel[];
107105 extern char gDescriptionMarketPlace[];
--- users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/display.s (revision 1711)
+++ users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/display.s (revision 1712)
@@ -125,6 +125,9 @@
125125 shiftTablePtr = tmp6
126126 fontPtr = tmp7
127127 scanlinePtr = reg0
128+prev_char = reg1
129+cur_char = reg2
130+kerning = reg3
128131
129132 end_of_string
130133 ; Update the pointer
@@ -183,7 +186,15 @@
183186 lda _gDrawPosY
184187 sta y_position
185188
189+ ; Reset the kerning
190+ lda #0
191+ sta cur_char
192+
186193 loop_character
194+ ; The kerning works with pairs of characters, so we need to keep track of the previous and next character
195+ lda cur_char
196+ sta prev_char
197+
187198 ; Fetch the next character from the string
188199 ; 0 -> End of string
189200 ; 13 -> Carriage return (used to handle multi-line strings) followed by a scanline count
@@ -191,6 +202,7 @@
191202 ; >=32 -> Normal ASCII characters in the 32-127 range
192203 ldy #0
193204 lda (messagePtr),y
205+ sta cur_char ; -- test
194206 beq end_of_string
195207 bmi negative_value
196208 cmp #13
@@ -256,11 +268,40 @@
256268 adc #<_gFont12x14
257269 sta fontPtr+0
258270 lda #0
271+ sta kerning ; By default, no kerning adjustment to apply
272+ tax ; x=0
259273 adc #>_gFont12x14
260274 sta fontPtr+1
261275
276+ ; Search in the kerning table for a matching prev/cur combination of characters
277+ ; We could store somewhere in the font (size table?) if it's even worth looking at all to avoid the lookup for some letters
278+ .(
279+loop_kerning
280+ lda _gFont12x14Kerning+0,x
281+ beq end_kerning
282+ cmp prev_char ; Check the first character
283+ bne next_pair
284+ lda cur_char
285+ cmp _gFont12x14Kerning+1,x ; Check the second character
286+ bne next_pair
287+
288+ lda _gFont12x14Kerning+2,x ; Store the associated kerning value
289+ sta kerning
290+ bne end_kerning
291+
292+next_pair
293+ inx
294+ inx
295+ inx
296+ bne loop_kerning
297+end_kerning
298+ .)
299+
300+
262301 ; Using the current x coordinate in the scanline, we compute the actual position on the screen where to start drawing the character
263302 lda x_position
303+ sec
304+ sbc kerning ; Subract the kerning value to group together closer some combinations of letters
264305 tax ; Keep the original current X value for later
265306 sec ; +1 because we don't want the characters to be glued together
266307 adc width_char
@@ -1432,6 +1473,27 @@
14321473 .byt %111110
14331474 .byt %111111
14341475
1476+; Kerning table: Pairs of characters associated with a value subtracted to the x position of the second character
1477+_gFont12x14Kerning
1478+ .byt "ff",2
1479+ .byt "fi",1
1480+ .byt "fa",2
1481+ .byt "fe",2
1482+ .byt "fo",2
1483+ .byt "ij",2
1484+ .byt "ig",1
1485+ .byt "Ja",2
1486+ .byt "op",1
1487+ .byt "Of",1
1488+ .byt "ro",1
1489+ .byt "rd",1
1490+ .byt "rk",1
1491+ .byt "rp",1
1492+ .byt "if",1
1493+ .byt "da",1
1494+ .byt "th",1
1495+ .byt "Th",1
1496+ .byt 0 ; End of table
14351497
14361498 ; 95 characters (from space to tilde), each is two byte large and 14 lines tall = 2660 bytes
14371499 _gFont12x14
--- users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/game_text.s (revision 1711)
+++ users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/game_text.s (revision 1712)
@@ -362,12 +362,11 @@
362362 #endif
363363 _EndItemNames
364364
365-_gTextLowerCaseAlphabet .byt "abcde",255-2,"f",255-2,"ghi",255-2,"jklmnopqrstuvwxyz",0
366365
367366
368367 // Scene descriptions
369368 _StartSceneScripts
370-_gDescriptionTeenagerRoom .byt "T",255-2,"eenager r",255-1,"oom?",0
369+_gDescriptionTeenagerRoom .byt "Teenager room?",0
371370
372371 _gDescriptionNone
373372 END
@@ -395,8 +394,13 @@
395394 _gDescriptionDarkAlley
396395 WAIT(DELAY_FIRST_BUBBLE)
397396 .byt COMMAND_BUBBLE,2,64
398- .byt 153,85,0,"Rats, graf",255-1,"f",255-1,"itti,",0
397+#ifdef LANGUAGE_FR
398+ .byt 153,85,0,"Rats, graffitti,",0
399399 .byt 136,98,0,"and used syringes.",0
400+#else
401+ .byt 153,85,0,"Rats, graffittis,",0
402+ .byt 136,98,0,"et seringues.",0
403+#endif
400404 END
401405
402406 _gDescriptionRoad
@@ -417,7 +421,7 @@
417421 WAIT(DELAY_FIRST_BUBBLE)
418422 .byt COMMAND_BUBBLE,2,64
419423 .byt 130,5,0,"Are these the open",0
420- .byt 109,17,0,"f",256-1,"lood gates of heaven?",0
424+ .byt 109,17,0,"flood gates of heaven?",0
421425 END
422426
423427 _gDescriptionInThePit
@@ -510,9 +514,9 @@
510514 _gDescriptionGravelDrive
511515 WAIT(DELAY_FIRST_BUBBLE)
512516 .byt COMMAND_BUBBLE,3,64
513- .byt 127,86,0,"Kind o",255-2,"f impressive",0
517+ .byt 127,86,0,"Kind of impressive",0
514518 .byt 143,97,0,"when seen from",0
515- .byt 182,107,0,"f",255-2,"ar away",0
519+ .byt 182,107,0,"far away",0
516520 END
517521
518522 _gDescriptionZenGarden
@@ -525,14 +529,14 @@
525529 _gDescriptionFrontLawn
526530 WAIT(DELAY_FIRST_BUBBLE)
527531 .byt COMMAND_BUBBLE,2,64
528- .byt 5,5,0,"The per",255-2,"f",255-2,"ect home",0
529- .byt 5,15,1,"f",255-2,"or egomaniacs",0
532+ .byt 5,5,0,"The perfect home",0
533+ .byt 5,15,1,"for egomaniacs",0
530534 END
531535
532536 _gDescriptionGreenHouse
533537 WAIT(DELAY_FIRST_BUBBLE)
534538 .byt COMMAND_BUBBLE,2,64
535- .byt 4,96,0,"Obviously f",255-2,"or",0
539+ .byt 4,96,0,"Obviously for",0
536540 .byt 4,107,1,"Therapeutic use",34,0
537541 END
538542
@@ -553,8 +557,8 @@
553557 _gDescriptionFishPond
554558 WAIT(DELAY_FIRST_BUBBLE)
555559 .byt COMMAND_BUBBLE,2,64
556- .byt 5,5,0,"Some of these f",255-1,"ishes",0
557- .byt 5,17,0,"are sur",255-1,"prinsingly big",0
560+ .byt 5,5,0,"Some of these fishes",0
561+ .byt 5,17,0,"are surprinsingly big",0
558562 END
559563
560564 _gDescriptionTiledPatio
@@ -567,8 +571,8 @@
567571 _gDescriptionAppleOrchard
568572 WAIT(DELAY_FIRST_BUBBLE)
569573 .byt COMMAND_BUBBLE,2,64
570- .byt 5,5,0,"The best kind o",255-2,"f apples:",0
571- .byt 5,17,0,"sweet",255-1,", crunchy and juicy",0
574+ .byt 5,5,0,"The best kind of apples:",0
575+ .byt 5,17,0,"sweet, crunchy and juicy",0
572576 END
573577
574578 _gDescriptionEntranceHall
@@ -592,7 +596,7 @@
592596 ; Text describing the growling dog
593597 WAIT(DELAY_FIRST_BUBBLE)
594598 .byt COMMAND_BUBBLE,2,64
595- .byt 5,5,0,"O",255-2,"f course there is a dog.",0
599+ .byt 5,5,0,"Of course there is a dog.",0
596600 .byt 5,19,0,"There's always a dog.",0
597601 END
598602
@@ -619,7 +623,7 @@
619623 WAIT(DELAY_FIRST_BUBBLE)
620624 .byt COMMAND_BUBBLE,2,64
621625 .byt 5,86,0,"Books, fireplace, and",0
622- .byt 5,97,0,"a com",255-2,"f",255-2,"ortable chair",0
626+ .byt 5,97,0,"a comfortable chair",0
623627 END
624628
625629 _gDescriptionNarrowPassage
@@ -626,7 +630,7 @@
626630 WAIT(DELAY_FIRST_BUBBLE)
627631 .byt COMMAND_BUBBLE,3,127
628632 .byt 5,48,0,"Either they love dark",0
629- .byt 12,68,0,"or they f",255-2,"orgot to",0
633+ .byt 12,68,0,"or they forgot to",0
630634 .byt 37,90,0,"pay their",0
631635
632636 .byt COMMAND_BUBBLE,1,64
@@ -650,7 +654,7 @@
650654 _gDescriptionGamesRoom
651655 WAIT(DELAY_FIRST_BUBBLE)
652656 .byt COMMAND_BUBBLE,2,64
653- .byt 142,5,0,"T",255-2,"op o",255-2,"f the range",0
657+ .byt 142,5,0,"Top of the range",0
654658 .byt 164,16,0,"video system",0
655659
656660 WAIT(50)
@@ -662,7 +666,7 @@
662666 _gDescriptionSunLounge
663667 WAIT(DELAY_FIRST_BUBBLE)
664668 .byt COMMAND_BUBBLE,1,64
665- .byt 112,5,0,"No rest ",255-2,"f",255-2,"or the weary",0
669+ .byt 112,5,0,"No rest for the weary",0
666670 END
667671
668672 _gDescriptionKitchen
@@ -723,8 +727,8 @@
723727 _gDescriptionGuestBedroom
724728 WAIT(DELAY_FIRST_BUBBLE)
725729 .byt COMMAND_BUBBLE,2,64
726- .byt 5,6,0,"Simple and ",255-2,"f",255-2,"resh",0
727- .byt 5,17,0,"f",255-2,"or a change",0
730+ .byt 5,6,0,"Simple and fresh",0
731+ .byt 5,17,0,"for a change",0
728732 END
729733
730734 _gDescriptionShowerRoom
Show on old repository browser