Replaced the manual kerning by a table of character pairs and some basic lookup code
@@ -100,8 +100,6 @@ | ||
100 | 100 | |
101 | 101 | |
102 | 102 | // game_text |
103 | -extern char gTextLowerCaseAlphabet[]; | |
104 | - | |
105 | 103 | extern char gDescriptionTeenagerRoom[]; |
106 | 104 | extern char gDescriptionDarkTunel[]; |
107 | 105 | extern char gDescriptionMarketPlace[]; |
@@ -125,6 +125,9 @@ | ||
125 | 125 | shiftTablePtr = tmp6 |
126 | 126 | fontPtr = tmp7 |
127 | 127 | scanlinePtr = reg0 |
128 | +prev_char = reg1 | |
129 | +cur_char = reg2 | |
130 | +kerning = reg3 | |
128 | 131 | |
129 | 132 | end_of_string |
130 | 133 | ; Update the pointer |
@@ -183,7 +186,15 @@ | ||
183 | 186 | lda _gDrawPosY |
184 | 187 | sta y_position |
185 | 188 | |
189 | + ; Reset the kerning | |
190 | + lda #0 | |
191 | + sta cur_char | |
192 | + | |
186 | 193 | 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 | + | |
187 | 198 | ; Fetch the next character from the string |
188 | 199 | ; 0 -> End of string |
189 | 200 | ; 13 -> Carriage return (used to handle multi-line strings) followed by a scanline count |
@@ -191,6 +202,7 @@ | ||
191 | 202 | ; >=32 -> Normal ASCII characters in the 32-127 range |
192 | 203 | ldy #0 |
193 | 204 | lda (messagePtr),y |
205 | + sta cur_char ; -- test | |
194 | 206 | beq end_of_string |
195 | 207 | bmi negative_value |
196 | 208 | cmp #13 |
@@ -256,11 +268,40 @@ | ||
256 | 268 | adc #<_gFont12x14 |
257 | 269 | sta fontPtr+0 |
258 | 270 | lda #0 |
271 | + sta kerning ; By default, no kerning adjustment to apply | |
272 | + tax ; x=0 | |
259 | 273 | adc #>_gFont12x14 |
260 | 274 | sta fontPtr+1 |
261 | 275 | |
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 | + | |
262 | 301 | ; Using the current x coordinate in the scanline, we compute the actual position on the screen where to start drawing the character |
263 | 302 | lda x_position |
303 | + sec | |
304 | + sbc kerning ; Subract the kerning value to group together closer some combinations of letters | |
264 | 305 | tax ; Keep the original current X value for later |
265 | 306 | sec ; +1 because we don't want the characters to be glued together |
266 | 307 | adc width_char |
@@ -1432,6 +1473,27 @@ | ||
1432 | 1473 | .byt %111110 |
1433 | 1474 | .byt %111111 |
1434 | 1475 | |
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 | |
1435 | 1497 | |
1436 | 1498 | ; 95 characters (from space to tilde), each is two byte large and 14 lines tall = 2660 bytes |
1437 | 1499 | _gFont12x14 |
@@ -362,12 +362,11 @@ | ||
362 | 362 | #endif |
363 | 363 | _EndItemNames |
364 | 364 | |
365 | -_gTextLowerCaseAlphabet .byt "abcde",255-2,"f",255-2,"ghi",255-2,"jklmnopqrstuvwxyz",0 | |
366 | 365 | |
367 | 366 | |
368 | 367 | // Scene descriptions |
369 | 368 | _StartSceneScripts |
370 | -_gDescriptionTeenagerRoom .byt "T",255-2,"eenager r",255-1,"oom?",0 | |
369 | +_gDescriptionTeenagerRoom .byt "Teenager room?",0 | |
371 | 370 | |
372 | 371 | _gDescriptionNone |
373 | 372 | END |
@@ -395,8 +394,13 @@ | ||
395 | 394 | _gDescriptionDarkAlley |
396 | 395 | WAIT(DELAY_FIRST_BUBBLE) |
397 | 396 | .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 | |
399 | 399 | .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 | |
400 | 404 | END |
401 | 405 | |
402 | 406 | _gDescriptionRoad |
@@ -417,7 +421,7 @@ | ||
417 | 421 | WAIT(DELAY_FIRST_BUBBLE) |
418 | 422 | .byt COMMAND_BUBBLE,2,64 |
419 | 423 | .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 | |
421 | 425 | END |
422 | 426 | |
423 | 427 | _gDescriptionInThePit |
@@ -510,9 +514,9 @@ | ||
510 | 514 | _gDescriptionGravelDrive |
511 | 515 | WAIT(DELAY_FIRST_BUBBLE) |
512 | 516 | .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 | |
514 | 518 | .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 | |
516 | 520 | END |
517 | 521 | |
518 | 522 | _gDescriptionZenGarden |
@@ -525,14 +529,14 @@ | ||
525 | 529 | _gDescriptionFrontLawn |
526 | 530 | WAIT(DELAY_FIRST_BUBBLE) |
527 | 531 | .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 | |
530 | 534 | END |
531 | 535 | |
532 | 536 | _gDescriptionGreenHouse |
533 | 537 | WAIT(DELAY_FIRST_BUBBLE) |
534 | 538 | .byt COMMAND_BUBBLE,2,64 |
535 | - .byt 4,96,0,"Obviously f",255-2,"or",0 | |
539 | + .byt 4,96,0,"Obviously for",0 | |
536 | 540 | .byt 4,107,1,"Therapeutic use",34,0 |
537 | 541 | END |
538 | 542 |
@@ -553,8 +557,8 @@ | ||
553 | 557 | _gDescriptionFishPond |
554 | 558 | WAIT(DELAY_FIRST_BUBBLE) |
555 | 559 | .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 | |
558 | 562 | END |
559 | 563 | |
560 | 564 | _gDescriptionTiledPatio |
@@ -567,8 +571,8 @@ | ||
567 | 571 | _gDescriptionAppleOrchard |
568 | 572 | WAIT(DELAY_FIRST_BUBBLE) |
569 | 573 | .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 | |
572 | 576 | END |
573 | 577 | |
574 | 578 | _gDescriptionEntranceHall |
@@ -592,7 +596,7 @@ | ||
592 | 596 | ; Text describing the growling dog |
593 | 597 | WAIT(DELAY_FIRST_BUBBLE) |
594 | 598 | .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 | |
596 | 600 | .byt 5,19,0,"There's always a dog.",0 |
597 | 601 | END |
598 | 602 |
@@ -619,7 +623,7 @@ | ||
619 | 623 | WAIT(DELAY_FIRST_BUBBLE) |
620 | 624 | .byt COMMAND_BUBBLE,2,64 |
621 | 625 | .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 | |
623 | 627 | END |
624 | 628 | |
625 | 629 | _gDescriptionNarrowPassage |
@@ -626,7 +630,7 @@ | ||
626 | 630 | WAIT(DELAY_FIRST_BUBBLE) |
627 | 631 | .byt COMMAND_BUBBLE,3,127 |
628 | 632 | .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 | |
630 | 634 | .byt 37,90,0,"pay their",0 |
631 | 635 | |
632 | 636 | .byt COMMAND_BUBBLE,1,64 |
@@ -650,7 +654,7 @@ | ||
650 | 654 | _gDescriptionGamesRoom |
651 | 655 | WAIT(DELAY_FIRST_BUBBLE) |
652 | 656 | .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 | |
654 | 658 | .byt 164,16,0,"video system",0 |
655 | 659 | |
656 | 660 | WAIT(50) |
@@ -662,7 +666,7 @@ | ||
662 | 666 | _gDescriptionSunLounge |
663 | 667 | WAIT(DELAY_FIRST_BUBBLE) |
664 | 668 | .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 | |
666 | 670 | END |
667 | 671 | |
668 | 672 | _gDescriptionKitchen |
@@ -723,8 +727,8 @@ | ||
723 | 727 | _gDescriptionGuestBedroom |
724 | 728 | WAIT(DELAY_FIRST_BUBBLE) |
725 | 729 | .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 | |
728 | 732 | END |
729 | 733 | |
730 | 734 | _gDescriptionShowerRoom |