Go Penguin WIP platformer for MSX 1

Page 8/10
1 | 2 | 3 | 4 | 5 | 6 | 7 | | 9 | 10

By santiontanon

Paragon (1390)

santiontanon's picture

05-05-2021, 16:43

Btw @albs_br, not sure if this is of interest to you, but just in case, I just tried my assembler optimizer in your codebase, and it found a few optimizations that you might be interested in:

INFO: Reorganization optimization in GameLogic/UpdateBgObjects.s#605: delete unreachable code in lines 605 - 605 1 bytes saved.
INFO: Reorganization optimization in GameLogic/GameLogic.s#250: move lines 250 - 255 to right before GameLogic/GameLogic.s#107 to remove a jump statement (3 bytes, 11 t-states saved)
INFO: Reorganization optimization in GameLogic/GameLogic.s#256: move lines 256 - 261 to right before GameLogic/GameLogic.s#250 to remove a jump statement (3 bytes, 11 t-states saved)
INFO: Reorganization optimization in GameLogic/Scroll.s#229: move lines 229 - 252 to right before GameLogic/Scroll.s#261 to remove a jump statement (3 bytes, 11 t-states saved)
INFO: Reorganization optimization in GameLogic/UpdateBgObjects.s#47: move lines 47 - 92 to right before GameLogic/UpdateBgObjects.s#114 to remove a jump statement (3 bytes, 11 t-states saved)
INFO: Reorganization optimization in GameLogic/UpdateBgObjects.s#47: move lines 47 - 117 to right before GameLogic/UpdateBgObjects.s#93 to remove a jump statement (3 bytes, 11 t-states saved)
INFO: Reorganization optimization in GameLogic/UpdateBgObjects.s#312: move lines 312 - 351 to right before GameLogic/UpdateBgObjects.s#365 to remove a jump statement (3 bytes, 11 t-states saved)
INFO: Reorganization optimization in Include/Vram.s#53: move lines Include/Vram.s#88-122 to right after Include/Vram.s#53 to remove a call and a ret statements as loadtilepatterns is only caled once (4 bytes, 29 t-states saved)
INFO: Reorganization optimization in Include/Vram.s#54: move lines Include/Vram.s#165-188 to right after Include/Vram.s#54 to remove a call and a ret statements as loadtilecolors is only caled once (4 bytes, 29 t-states saved)
INFO: Reorganization optimization in Include/Vram.s#50: move lines Include/CommonRoutines.s#225-234 to right after Include/Vram.s#50 to remove a call and a ret statements as clearvram is only caled once (4 bytes, 29 t-states saved)
INFO: Reorganization optimization in GameLogic/GameLogic.s#129: move lines GameLogic/UpdateSpriteAttrTableBuffer.s#1-109 to right after GameLogic/GameLogic.s#129 to remove a call and a ret statements as updatespriteattrtablebuffer is only caled once (4 bytes, 29 t-states saved)
INFO: Reorganization optimization in GameLogic/Scroll.s#34: move lines GameLogic/Scroll.s#342-386 to right after GameLogic/Scroll.s#34 to remove a call and a ret statements as drawbackground_1st_third is only caled once (4 bytes, 29 t-states saved)
INFO: Reorganization optimization in GameLogic/Scroll.s#54: move lines GameLogic/Scroll.s#387-430 to right after GameLogic/Scroll.s#54 to remove a call and a ret statements as drawbackground_2nd_third is only caled once (4 bytes, 29 t-states saved)
INFO: Reorganization optimization in GameLogic/Scroll.s#77: move lines GameLogic/Scroll.s#431-474 to right after GameLogic/Scroll.s#77 to remove a call and a ret statements as drawbackground_3rd_third is only caled once (4 bytes, 29 t-states saved)
INFO: Reorganization optimization in Include/CheckCollision.s#120: detected this code is identical to that in Include/CheckCollision.s#94 delete lines Include/CheckCollision.s#120 - 128 and move label 'checkcollision_16x16_16x16_vertical.y1islarger' right after 'checkcollision_16x16_16x16.y1islarger' (5 bytes, 0 t-states saved)
INFO: Reorganization optimization in Include/CheckCollision.s#146: detected this code is identical to that in Include/CheckCollision.s#94 delete lines Include/CheckCollision.s#146 - 154 and move label 'checkcollision_16x16_16x16_horizontal.x1islarger' right after 'checkcollision_16x16_16x16.y1islarger' (5 bytes, 0 t-states saved)
INFO: CodeReorganizer moves: 16, 57 bytes, 269 t-states saved.
INFO: Pattern-based optimization in Include/Vram.s#17: Remove duplicate ld a,color_black (2 bytes, 8 t-states saved)
INFO: Pattern-based optimization in Include/Vram.s#40: Replace ld c,1; ld b,0b11100010 with ld bc,((1) & #00ff) + ((0b11100010) << 8) (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in Include/Vram.s#85: Replace call bios_enascr; ret with jp bios_enascr (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in Include/CommonRoutines.s#15: Replace ld d,0x06; ld e,0xff with ld de,((0xff) & #00ff) + ((0x06) << 8) (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in Include/CommonRoutines.s#114: Replace call bios_wrtvrm; ret with jp bios_wrtvrm (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in Include/CommonRoutines.s#206: Replace call fillcolortable; ret with jp fillcolortable (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in Include/CommonRoutines.s#278: Replace call bios_enaslt; ret with jp bios_enaslt (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in Include/CommonRoutines.s#423: Replace call bios_wrtvrm; ret with jp bios_wrtvrm (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/GameLogic.s#114: Replace cp 1 with dec a (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateSpriteAttrTableBuffer.s#37: Replace ld a,color_dark_blue; ld (hl),a with ld (hl),color_dark_blue (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateSpriteAttrTableBuffer.s#55: Replace ld a,color_white; ld (hl),a with ld (hl),color_white (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateSpriteAttrTableBuffer.s#72: Replace ld a,color_white; ld (hl),a with ld (hl),color_white (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateSpriteAttrTableBuffer.s#89: Replace ld a,color_white; ld (hl),a with ld (hl),color_white (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in GameLogic/GameLogic.s#134: Replace ld a,(player_y); add 2; ld (player_y),a with ld hl,player_y; ld a,(hl); add 2; ld (hl),a (1 bytes, 1 t-states saved)
INFO: Pattern-based optimization in GameLogic/GameLogic.s#171: Replace cp 1 with dec a (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/GameLogic.s#220: Replace ld a,(player_animation_frame); inc a; ld (player_animation_frame),a with ld hl,player_animation_frame; inc (hl); ld a,(hl) (2 bytes, 2 t-states saved)
INFO: Pattern-based optimization in GameLogic/GameLogic.s#235: Replace ld a,(player_animation_frame); inc a; ld (player_animation_frame),a with ld hl,player_animation_frame; inc (hl); ld a,(hl) (2 bytes, 2 t-states saved)
INFO: Pattern-based optimization in GameLogic/ReadInput.s#30: Replace bit 7,a; jp z,readinput.playerright with rla; jp nc,readinput.playerright (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in GameLogic/Scroll.s#95: Replace call updatebgobjects_execute; ret with jp updatebgobjects_execute (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/Scroll.s#107: Replace call scrollright; ret with jp scrollright (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/Scroll.s#110: Replace call scrollleft; ret with jp scrollleft (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/Scroll.s#113: Replace call drawbackground_3_thirds; ret with jp drawbackground_3_thirds (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/Scroll.s#174: Replace ld a,c; neg with xor a; sub c (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in GameLogic/Scroll.s#226: Replace call drawbackground_3_thirds; ret with jp drawbackground_3_thirds (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/Scroll.s#259: Replace call drawbackground_3_thirds; ret with jp drawbackground_3_thirds (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/Scroll.s#250: Replace cp 255 with inc a (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/Scroll.s#339: Replace call drawbackground_3_thirds; ret with jp drawbackground_3_thirds (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/CheckBackGround.s#17: Replace srl a; ...; srl a with rrca; ...; rrca; and #ff >> 3 (1 bytes, 7 t-states saved)
INFO: Pattern-based optimization in GameLogic/CheckBackGround.s#44: Replace srl a; ...; srl a with rrca; ...; rrca; and #ff >> 3 (1 bytes, 7 t-states saved)
INFO: Pattern-based optimization in GameLogic/CheckBackGround.s#90: Replace srl a; ...; srl a with rrca; ...; rrca; and #ff >> 3 (1 bytes, 7 t-states saved)
INFO: Pattern-based optimization in GameLogic/CheckBackGround.s#116: Replace srl a; ...; srl a with rrca; ...; rrca; and #ff >> 3 (1 bytes, 7 t-states saved)
INFO: Pattern-based optimization in GameLogic/CheckBackGround.s#208: Replace call checkbackground_right; ret with jp checkbackground_right (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/CheckBackGround.s#227: Replace call checkbackground_left; ret with jp checkbackground_left (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/CheckBackGround.s#269: Replace call checkbackground_right; ret with jp checkbackground_right (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#23: Replace srl a; ...; srl a with rrca; ...; rrca; and #ff >> 4 (2 bytes, 12 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#81: Remove unnecessary and a / or a (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#295: Remove unused ld a,(hl) (1 bytes, 8 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#335: Replace cp 0 with or a (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#337: Replace cp 1 with dec a (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#392: Replace ld bc,8 with ld c,(8) & #00ff (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#400: Replace ld bc,8 with ld c,(8) & #00ff (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#408: Replace ld bc,8 with ld c,(8) & #00ff (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#416: Replace ld bc,8 with ld c,(8) & #00ff (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#424: Replace ld bc,8 with ld c,(8) & #00ff (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#521: Replace inc a; add a, 12 with add a, (12)+1 (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#544: Replace ld e,14 with ld e,c (as c == 14 here) (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#555: Replace ld a,2; ld (hl),a with ld (hl),2 (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in GameLogic/UpdateBgObjects.s#612: Remove duplicate xor a (1 bytes, 5 t-states saved)
INFO: Pattern-based optimization in Sound/Sound.s#46: Replace call bios_wrtpsg; ret with jp bios_wrtpsg (1 bytes, 18 t-states saved)
INFO: Pattern-based optimization in GameLogic/InitVariables.s#48: Replace ld hl,tilemap_leveltest_start with ld h,(tilemap_leveltest_start) >> 8 (1 bytes, 3 t-states saved)
INFO: PatternBasedOptimizer: 50 patterns applied, 54 bytes, 445 t-states saved.
INFO: mdl optimization summary: 111 bytes, 714 t-states saved. CodeReorganizer moves: 16. Pattern-based optimizer pattern applications: 50.

If you want to reproduce this, you can just check the latest version: https://github.com/santiontanon/mdlz80optimizer/releases/tag...

copy the mdl.jar to your project folder, and then just call:

java -jar mdl-2.0-jar-with-dependencies.jar main.s -dialect tniasm -po -ro

By santiontanon

Paragon (1390)

santiontanon's picture

05-05-2021, 16:43

Again, thanks a lot for making things open source, I was able to fix a few compatibility issues with tniasm thanks to your codebase Smile

By albs_br

Champion (265)

albs_br's picture

05-05-2021, 18:27

Thanks a lot. I never used your Optimizer, will take a look.
Some parts of the codebase are purposefully not optimized to be more readable and easilly changed in this development phase.
But for the core engine any optimization is critical, as the game is running close to the limits of the frame at 60 Hz (and I want 60 fps, very few parts of the code can be skipped to next(s) frame(s)).

By santiontanon

Paragon (1390)

santiontanon's picture

05-05-2021, 20:22

Indeed, I think that's a good idea. There are some optimizations that MDL proposes that I never do until the very end (or just ask MDL to do them automatically to generate the ROM without me ever changing to source), as they mess up readability really bad. But it's still interesting some times to see where can bytes or cycles be gained Smile

By santiontanon

Paragon (1390)

santiontanon's picture

06-05-2021, 04:15

Also, one detail, maybe tniasm does not complain, but in line 273 of BgObject.s:

ds     96 - ($ - (BgObjectsInitialState_Start + 0x06a0)), 0                 ; fill with 0s until end of block

The expression 96 - ($ - (BgObjectsInitialState_Start + 0x06a0)) evaluates to -8, since the previous block of data is actually larger than 96 bytes (MDL complains about that). Just letting you know in case it's a bug Smile

By albs_br

Champion (265)

albs_br's picture

06-05-2021, 04:46

Very well noted, @santiontanon. Indeed it was causing a bug and I had it already marked with a comment:
; TODO: fix bug (verify why this is not showing)

This data structure previously was 4 bytes long, I changed to 8 and it exceeded the 96 bytes limit (tniAsm really don't warned).

Now you fixed a bug for me. Thanks Smile

By santiontanon

Paragon (1390)

santiontanon's picture

06-05-2021, 05:01

Fantastic!! Glad it was helpful! Smile

By albs_br

Champion (265)

albs_br's picture

18-05-2021, 05:55

Hi guys, lately I worked some optimizations and here is the result:

In the very same scene, 17 lines, meaning 17 x 228 = 3876 cycles saved, which means I can put some more enemies on the same screen. Unfortunally not using the TCL script to measure timing yet.

Now alternating between 2 names table which means I don't have to worry about drawing some object before the scanline gets to it's Y position (kind of Atari's 2600 "running the beam"). I'm always writing to one names table while the other is being displayed. Much better this way.

Another improvement: copying all 48 bytes of enemy pattern to VRAM at once, instead of 6 x 8 separate operations. The more bytes you push at time, the faster.

Hopefully next time there will be some visible progress for the player.

Play online link:
https://webmsx.org/?MACHINE=MSX1&ROM=https://github.com/albs...

By Pbk71

Expert (97)

Pbk71's picture

23-05-2021, 08:33

I'm really looking forward to an updated version!
If you need some feedback to improve your game, please let me know. I'm not posting any now as you might already be working on the thing I would mention.

By albs_br

Champion (265)

albs_br's picture

09-06-2021, 04:59

Hi guys,
new version here:
https://youtu.be/4YuuLH42bIQ
Now with moving enemies (they move fast, I know) and a Score with lives, diamonds count and a time remaining bar.
The score is made of sprites, which is a thing not very common on MSX1. Not working yet, just mockup, to make the game looks better and more professional (improves morale of the developer).
As usual many improvements under the hood, most of them I don't even remember.

For each version the pace seems to become slower and slower, maybe I'm getting a bit tired of the project.

One good news is that the logic for enemy (red lines) is 90% complete and is using very few cycles (even I haven't optimized yet). So, I can put many enemies on the same screen. Remaining time (purple) are confortable.

Link to play online is the same: https://webmsx.org/?MACHINE=MSX1&ROM=https://github.com/albs...

@Pbk71, yes, any feedback both from players and developers are much appreciated.

Let me know your impressions.

Page 8/10
1 | 2 | 3 | 4 | 5 | 6 | 7 | | 9 | 10