From c20a27f02e38fa09f5c8fec1b7cd7e1d2d9cf635 Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Wed, 19 Jun 2019 15:07:02 +0000 Subject: [PATCH] Updated text renderer a bit --- assets/page1.chr | Bin 4096 -> 4096 bytes assets/page1_backup.chr | Bin 0 -> 4096 bytes game/game.asm | 9 +-- game/text.asm | 162 ++++++++++++++++++++++++---------------- main.asm | 21 +++++- main.o | Bin 7649 -> 8045 bytes test.gb | Bin 32768 -> 32768 bytes test.map | 49 ++++++------ test.sym | 37 ++++----- tools.asm | 16 ++++ 10 files changed, 177 insertions(+), 117 deletions(-) create mode 100644 assets/page1_backup.chr diff --git a/assets/page1.chr b/assets/page1.chr index bdd12507a23373f5c80fa0baa7ec38356f51a478..b98abcdebf8a30cb797be1beeea360ddeabbd15f 100644 GIT binary patch literal 4096 zcmeHHy-!n76ui*y!=wP z%!l%k2**WyYyQYu>J|SI&Q)-ksEg4_#Gg2_FbDBX@g+J%Ae_3?6Kd5R&%T7*Irxyh zwv@NTU%+{Yh)(%LT6Nuz;8bxCrwT>i2b=5EIQ35)QT+34a#`3*iOC;;7}YX3^In3@Lop z`Fl*E|286V7K&}76cDd6PX0D_L^-H_7m+aAQVxkvh{ok)HT|hxksQ|G*OS0AJv46- zI;*Bo^c-s`td_n=#*{L7`TrtWUcNrd%h#XsI;rb88rN~OuHy{wQcB-<^YZmGytE!w z)6uJ4_oH`*(y_72`TmMZS3V`mm8#KS+gkX1z1g4c6v^Fz*RaueQzrp70C|xObV4_L zg&)Je`bfme-{scd1=(o4#;7)iY3B3disg^tuNbwHV70ug)Y6jwkRH6#y1onQbPk2Y zUhZFvPe#TEQn7S28JF(ZCo_FP{QWn#ei~k`{jP^pI)u4>!?x9X&h^|C@j7d{-t~=lgLgh_6hnb_DT{QwL@yv>YE9oW7EYTngVAnpUp!Grl`# zZM!`)#&hK7-}s_oA)oU%wf`OF_xOwN{{a1u9_Ay1-RI8sb@Xt-{|?)yHUn)2+6=TAXf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-S#6b)FBn5aqII zs{NQ|w;M|I`-o?n$H#GON??DE6Na^#Y4&*~pM`MzvG9=#MuK{?w+x`*{oWXhJKJ1^wZ&G`S5&uVa?~}S523$(B75rKmB~I zQEP2}QoXwu(0=gt<Tdy?J1mEM1Pdthv>zVZ6{ z%9^H^)+q|2bOLtzuVoLo47p$cWDDfF7*y zek=O5wEl;7alb9v-Q1~S|4J8hc)qc~{zF-R@m*cATile map + ld c, a ; Set the position of C to the ASCII byte of current character + ld a, [bc] ; Get the tile byte for the ASCII from the map + ld [hl], a ; Print the byte to the map ld a, [de] and a ; Check if we reached the end - jr nz, .continue + jr nz, .checkNewline + ; We have reached the end of the string, disable textwriter + ld b, 0 ; Disable repeater ld a, 0 ld [textwriter_active], a + jr .continue ; Jump straight to continue. No need to check anything + +.checkNewline + ld a, [de] ; Regrab the ascii byte we printed + cp a, $0A ; Check if it was a new line + jr nz, .checkRepeatOnce ; Jump to checkRepeatOnce if it wasn't a new line + + ; The byte we printed was a new line so we increment Y position + ; and reset our X position. + ld a, 0 ; Usually we'd print into first position but since we're jumping + ; into continue, continue will automatically increment x for us. + ld [textwriter_posx], a + ld a, [textwriter_posy] + inc a + ld [textwriter_posy], a + + ; We already know we printed empty character so we can skip checking + ; if we need to repeat once again and just set the b flag + ld b, 1 + jr .continue + +.checkRepeatOnce + ld a, [bc] ; Regrab the tile we printer + ld b, 0 ; Use b as our marker if we should repeat once + + ; Check if we printed an empty letter + cp a, $50 + jr nz, .continue + ld b, 1 + .continue ; Time to update our work ram - ; Load the position pointer of current text to next letter + inc de ; Increment de to next letter + ; Load the position pointer of current text and update it to the next letter ld hl, textwriter_curtext - inc de ; Increment to next letter in string ld a, d ld [hli], a ld a, e @@ -135,56 +206,15 @@ DrawActiveText: ; Update the current letter being drawn in ram ld a, [textwriter_curletter] inc a + + ; Check if we need to repeat whole thing due to printing empty character + ld a, b + and b + jr nz, .startdrawtext + + ; We didn't print an empty ld [textwriter_curletter], a .exit ld a, [textwriter_active] ret - - -; Print String on screen -; @param b - PosX on where to draw text -; @param c - PosY on where to draw text -; @param de - Address source string -; @return a -; @return b -; @return c -; @return hl - Destination memory in map -; @return hl = Address Target to the byte after the last byte on the target (garbage) -PrintString: - ld hl, _SCRN0 ; Load the top-left map position to our map -.moveyaxis2 - ; Our first objective is to position the text to correct position - ; We do so shifting the position by $20 for each y axis - ; and position by $01 for each x axis that needs movement - ld a, c ; Load the y position to our accumilator - and a ; Check if it's zero - jr z, .movexaxis2 ; Jump to x axis if it's zero and no moving necessary - ld a, l ; Load the first half of the destination position - add a, $20 ; Add $20 (one vertical line) - ld l, a ; Store the position back - ld a, b ; Grab the second part of the address - adc a, $00 ; Add only the accumilator - ld b, a ; Store the position back - dec c ; Decrement our y parameter - jr .moveyaxis2 ; Repeat -.movexaxis2 - ; Now we check and move the position based on the x position - ld a, b ; Load the x position to our accimulator - and a ; Check if it's zero - jr z, .start2 ; Jump to start2 if it's zero already - inc hl ; Increment the map position by one since we need to move by x position - dec b ; Decrement our x parameter - jr .movexaxis2 ; Repeat -.start2 - ld a, [de] ; Load the first byte in the string - ld [hl], a ; Write the byte from the accumilator to the destination address - ; Also increment destination by one. - ; This effectively prints the character byte in accumilator - inc de ; Increment to next byte in string - inc hl - and a ; And together a with itself. This sets the flag - jr nz, .start2 ; Go back to start if we didn't just copy a zero. - ret - - diff --git a/main.asm b/main.asm index cab609e..663700a 100644 --- a/main.asm +++ b/main.asm @@ -59,11 +59,26 @@ Start: ld [rNR52], a ; Turn off sound + ld a, 7 + ld [rWX], a + ld a, (SCRN_Y - 32) + ld [rWY], a + + ; Reset OAM memory with zeros + ld hl, _OAMRAM ; Set position of OAM Ram to hl + ld a, 0 ; Fill that memory space with zero + ld b, $FEA0 - _OAMRAM ; Get the full size of the fill + call Memfill + + ; Initialize other stuff + call InitWindow + ; Turn the screen on, display background - ld a, LCDCF_ON|LCDCF_BGON - ; ld a, %10000001 ; screen on = 8th bit, background display = 1st bit + ld a, LCDCF_ON|LCDCF_BGON|LCDCF_WINON|LCDCF_WIN9C00 ld [rLCDC], a ; Set the screen flags - ei ; Enable interrupts again? + + call WaitVBlank + jp GameLoop SECTION "Font", ROM0 diff --git a/main.o b/main.o index d1a1e9a9b779c7333a23609781e3ce459cdc2b13..ab626f637160f80bd4691b995e93413528682b8c 100644 GIT binary patch literal 8045 zcmeHLZA@HQ89p$~K!FyvQ_7U$_ENUrElgV$P-lmstqZ$tWi0d~Cc7{TciTyaxszdl zsijI4lO~cZiH&U{yArLoF&pa|VocoBG42|uu=>Ziu8A3w#!#|}Y|^+D3D@U6=YGtc z3;4%>a!$^j^PcDZe$P4g!kLz1^_7gVO&F);-q*vC2xAFFiS*Tk`g&OzmYo@^5Fk|dus8_Bfi1RzZM=ck_%HJbLLRYfcU7T5%$Y2k3C&B}AHgmql zOhOsVF{Lk=&6=mNk~>ybn+p^jH4@2SMTA6UE2g;gb|M}cZ04SJQ225(Y-9fjyd*M* zk;UGt49Lk)GTfJKVpNm4xw6cam1M4IGT*ez^uWuNYefdgxp9n)$a_PvY?lhbk%K`k zD~#?-a`)vg%7c+`)K;(`f}ITfbOkXbng~bxZ6d$cL_SzSge;wrV{$0b7VWl4{z8*{ z-!9pg2*neWhm|U-XmY3>Yn3Ar<-8J)^t31RtxfxzZ|zbr==-XjG*Z>GGj&?i){I|k zrm{IZHO^P?dp;CSoI4f?MK7Zg#@X8s#EC&ivjtw9Qj}OtZzvp%V4|rryej|`?RGjG zILF;FY;;pq5mreRHSLtw#Ca-T%sTKAIEa%DJdctwGRZSQ_e3!UwP5I?d^iI;hqa9y z(XcN>doth)I*cs76b&cNhoe2pV0KQP1($xp^oX+qCFk^8CLZeTG@%nRBedF~Ps-*Gyj;a7Xj*i!# zt!l?(+Rx^5*}RkabLL%a-ofVcAj`h8^XlM%=|va2`*4meI++g~%Y}^$+)l#JRlf=g zi+QYV(ZO1-+}+Er{Z>+jK42F&dRP)C$%5iI^q0~n#xy+ZGkjO*0GQ9`!(pENKB!9umV~iZC_jM|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U8zviafB7y19RzVd!AbXDH(t)6oKLf1uixqqwYy4L3#4R3CVt?LV}3G8l- zk!AiKo*vM%mOrkZwD~;WA69jn=ZURy{ceYE@qTIjVSD|c8B$#P^?b_Fws}A_4&r009sH0T2KI5C8!X009sH0T2KI5C8!X z009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH z0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI y5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X0D=DxfxiIA^9Oza diff --git a/test.map b/test.map index 26c0b98..1956e39 100644 --- a/test.map +++ b/test.map @@ -1,39 +1,40 @@ ROM Bank #0 (HOME): SECTION: $0200-$027F ($0080 bytes) ["ram_textmap"] $0200 = textwriter_map - SECTION: $0150-$01F5 ($00A6 bytes) ["TextWriter"] - $01D0 = DrawActiveText.exit - $01A2 = DrawActiveText.movexaxis - $0193 = DrawActiveText.moveyaxis - $01AA = DrawActiveText.drawletter - $01BA = DrawActiveText.continue - $01E6 = PrintString.movexaxis2 - $01D7 = PrintString.moveyaxis2 - $01EE = PrintString.start2 - $0150 = StartText - $016C = DrawActiveText - SECTION: $0061-$0074 ($0014 bytes) ["Game Loop"] - $0061 = GameLoop.wait - $006D = GameLoop.mainloop - $0061 = GameLoop - SECTION: $0075-$0085 ($0011 bytes) ["Hello wrold string"] - $0075 = HelloWorldStr - SECTION: $0031-$003C ($000C bytes) ["Tools"] - $003A = WaitVBlank - $0031 = Memcpy + SECTION: $1280-$136B ($00EC bytes) ["TextWriter"] + $1368 = DrawActiveText.exit + $1314 = DrawActiveText.movexaxis + $1305 = DrawActiveText.moveyaxis + $131C = DrawActiveText.drawletter + $1330 = DrawActiveText.checkNewline + $134E = DrawActiveText.continue + $1345 = DrawActiveText.checkRepeatOnce + $12F4 = DrawActiveText.startdrawtext + $12C1 = StartText + $12DD = DrawActiveText + $1280 = InitWindow + SECTION: $0031-$003E ($000E bytes) ["Game Loop"] + $0037 = GameLoop.mainloop + $0031 = GameLoop + SECTION: $0000-$001F ($0020 bytes) ["Hello wrold string"] + $0000 = HelloWorldStr + SECTION: $0020-$0030 ($0011 bytes) ["Tools"] + $0029 = Memfill + $002E = WaitVBlank + $0020 = Memcpy + $0029 = Memfill.repeatFill SECTION: $0040-$0040 ($0001 bytes) ["InterruptVblank"] SECTION: $0048-$0048 ($0001 bytes) ["InterruptLCDC"] SECTION: $0050-$0050 ($0001 bytes) ["InterruptTimer_Overflow"] SECTION: $0058-$0058 ($0001 bytes) ["InterruptSerial"] SECTION: $0060-$0060 ($0001 bytes) ["Interruptp1thru4"] SECTION: $0100-$014F ($0050 bytes) ["Header"] - SECTION: $0000-$0030 ($0031 bytes) ["Intro code"] - $0000 = Start - $0000 = Start.waitVBlank + SECTION: $0061-$00A1 ($0041 bytes) ["Intro code"] + $0061 = Start SECTION: $0280-$127F ($1000 bytes) ["Font"] $0280 = Page1 $1280 = Page1End - SLACK: $2E23 bytes + SLACK: $2DBF bytes WRAM Bank #0: SECTION: $C000-$C006 ($0007 bytes) ["ram_textwriter"] diff --git a/test.sym b/test.sym index 9646501..41425ae 100644 --- a/test.sym +++ b/test.sym @@ -1,24 +1,25 @@ ; File generated by rgblink 00:0200 textwriter_map -00:01D0 DrawActiveText.exit -00:01A2 DrawActiveText.movexaxis -00:0193 DrawActiveText.moveyaxis -00:01AA DrawActiveText.drawletter -00:01BA DrawActiveText.continue -00:01E6 PrintString.movexaxis2 -00:01D7 PrintString.moveyaxis2 -00:01EE PrintString.start2 -00:0150 StartText -00:016C DrawActiveText -00:0061 GameLoop.wait -00:006D GameLoop.mainloop -00:0061 GameLoop -00:0075 HelloWorldStr -00:003A WaitVBlank -00:0031 Memcpy -00:0000 Start -00:0000 Start.waitVBlank +00:1368 DrawActiveText.exit +00:1314 DrawActiveText.movexaxis +00:1305 DrawActiveText.moveyaxis +00:131C DrawActiveText.drawletter +00:1330 DrawActiveText.checkNewline +00:134E DrawActiveText.continue +00:1345 DrawActiveText.checkRepeatOnce +00:12F4 DrawActiveText.startdrawtext +00:12C1 StartText +00:12DD DrawActiveText +00:1280 InitWindow +00:0037 GameLoop.mainloop +00:0031 GameLoop +00:0000 HelloWorldStr +00:0029 Memfill +00:002E WaitVBlank +00:0020 Memcpy +00:0029 Memfill.repeatFill +00:0061 Start 00:0280 Page1 00:1280 Page1End 00:C002 textwriter_curletter diff --git a/tools.asm b/tools.asm index 0a8438b..b0017be 100644 --- a/tools.asm +++ b/tools.asm @@ -18,6 +18,22 @@ Memcpy: jr nz, Memcpy ; Loop back to Memcpy if not zero ret +Memfill: +; Fill an area in memory at position hl with value a for b amount of times +; +; @param hl - Starting address in memory to fill +; @param a - The value to fill said address space with +; @param b - How many bytes we should fill starting from said address space +; @return a - garbage +; @return b - PosX on where to draw text +; @return c - PosY on where to draw text +; @return hl - Workram position for text pointer +; @return de - Memory address to source string +.repeatFill + ld [hli], a + dec b + jr nz, .repeatFill + ret ;; ; Waits for the vblank ISR to increment the count of vertical blanks.