CPCWiki forum

General Category => Games => Topic started by: 40Crisis on 21:24, 17 September 20

Title: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 21:24, 17 September 20
Hello,

This is my lame attempt to emulate GB Tetris on a CPC ;D For everyone tranquility, please never include tetris rom in distribution package.
Enjoy.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 21:32, 17 September 20
Whoa, got to see this.

So I've dumped my original cart, how do I run it?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 21:36, 17 September 20
You're absolutely right...Read the txt file in the archive for instructions
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 22:02, 17 September 20
Ah apologies, I'm on the mobile and I didn't notice it was a zip file. All is clear.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: jackic on 22:03, 17 September 20
Is this for real? I can't make it work, I tried both versions of the tetris rom I own, 1.0 and 1.1 seems to load something but the only feature that seems to work is the palette change.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 22:35, 17 September 20
A little help:- Only works on a CPC 6128 or CPC 6128+ - Rom file name on CPC disk must be rom.bin

Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Skunkfish on 07:18, 18 September 20
Really odd, the error I seem to be getting is a 'Syntax error in 70' which is 'load "!rom.bin",&2000

I try that outside of the program and get the same result?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: pelrun on 07:29, 18 September 20
How are you getting the rom into the dsk image? It's really easy to add it without the amsdos header and then nothing will work right.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Skunkfish on 07:30, 18 September 20
Just realised that mistake, I'm now enjoying some Tetris goodness on my Plus!
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Liartes on 08:01, 18 September 20
As the GB hardware is more-or-less Z80 based, is your application emulating all the GB or "just" some parts ?
Anyway I am impressed !
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Skunkfish on 08:05, 18 September 20
It's really impressive indeed, I wonder if other games would be possible? I imagine Super Mario Land may struggle with the scrolling...?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: flibblesan on 08:14, 18 September 20
Very very cool and impressive work!

Runs nicely in WinApe.  :)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Xyphoe on 08:20, 18 September 20
Well now, that is just BRILLIANT! GREAT JOB!

So I had a little trouble with this to start with, so I'll clarify some things....

1) Use the "ManageDSK" tool -> http://www.cpcwiki.eu/index.php/ManageDsk (http://www.cpcwiki.eu/index.php/ManageDsk)
2) You'll want the the v1.1 rom of Tetris, v1.0 did not work for me at all.
3) Rename it to "rom.bin" as the guide says, and import as a BINARY (not ASCII) file in ManageDSK and save the disk.
4) This should work in say Winape which I tested in, but make sure you're in 6128 or 6128 Plus mode (I tested with the latter).

:)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: pelrun on 08:28, 18 September 20
Quote from: Liartes on 08:01, 18 September 20
As the GB hardware is more-or-less Z80 based, is your application emulating all the GB or "just" some parts ?
Luckily the GB CPU is entirely a subset of the Z80, so most of the code will run directly - emulation would be far too slow. Hardware access is another thing altogether so the appropriate bits of the rom would be replaced with CPC specific code instead.
The rom banking on the GB is very different, so I expect only the small number of games which didn't use a mapper at all (https://gbhwdb.gekkio.fi/cartridges/no-mapper.html (https://gbhwdb.gekkio.fi/cartridges/no-mapper.html)) could be ported this way. SML would be right out :D
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: pelrun on 08:47, 18 September 20
Also - "lame attempt"? It runs perfectly! Even the sound works! This is fantastic!
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Xyphoe on 09:12, 18 September 20
Been playing a bit now, and it plays perfectly!
The only thing a bit off is some of the sound emulation for the title screen music, and some in game sfx. Can that be fixed or is that impossible?
(Not saying you should, I'm more than happy with what we've got!)

Suggestion - a 6128 Plus version with more options on the palette, so we can more accurately emulate the GB's colours :)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 09:22, 18 September 20
Quote from: Xyphoe on 09:12, 18 September 20Suggestion - a 6128 Plus version with more options on the palette, so we can more accurately emulate the GB's colours


Well the included text says:

Change display palette: 0 Key (18 different sets of palettes)
GB cursor: Arrows keys or OPQA keys or joystick
Start: Enter or Return Key
Select: Space Bar Key
A button: Tab Key or Joy Fire 1
B button: CapsLock Key or Joy Fire 2
Emulate original GB palette on CPC+: 4 keys combination plus (will crash if used on a non + machine).
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: pelrun on 09:35, 18 September 20
That description is incredibly vague, apparently it means you hold down the keys P L U S together to switch.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Xyphoe on 10:09, 18 September 20
OH wow.
I totally missed that. My bad.
And yes, you have to hold down the keys P L U S and it works! woo! It gets EVEN better!!
Definitely going to feature this on tonight's AMSTREAM on YouTube, especially because it's an Amstrad 464/6128 Plus special tonight - and we have a Plus palette here!
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Xyphoe on 10:36, 18 September 20
A minor thing to report - got to the ending on Type A - the rocket ship taking off is quite glitchy and flickery. Not complaining, just reporting things as I find.
I'm absolutely loving this of course :)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 14:57, 18 September 20
Dear 40Crisis,

A GB emulator on CPC was a nice challenge "expected" since years.
It is really great to achieve that with Tetris!  8)

Congratulations,

  TotO
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Redbug on 15:05, 18 September 20
Ok..
You break the game :(
My port seems so.... a waste of time...


https://www.facebook.com/redbug/videos/10158439917016668/?t=3 (https://www.facebook.com/redbug/videos/10158439917016668/?t=3)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 15:33, 18 September 20
Wait what?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: pelrun on 15:39, 18 September 20
Quote from: Redbug on 15:05, 18 September 20
My port seems so.... a waste of time...


Redbug just posted a comment practically saying the same thing about his port after seeing yours  :o
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Redbug on 16:39, 18 September 20
Quote from: pelrun on 15:39, 18 September 20

Redbug just posted a comment practically saying the same thing about his port after seeing yours  :o


?? I don't understand. You quote me to say that I have said the quote ? ;)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 16:41, 18 September 20
We have to go deeper.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: pelrun on 17:18, 18 September 20
Oops, I totally thought it was 40Crisis who posted that  :picard2: :doh:
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 18:43, 18 September 20
Quote from: 40Crisis on 21:24, 17 September 20
This is my lame attempt to emulate GB Tetris on a CPC ;D
Can we expect to have something like that? (very WIP theme)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 19:48, 18 September 20
Quote from: Liartes on 08:01, 18 September 20
As the GB hardware is more-or-less Z80 based, is your application emulating all the GB or "just" some parts ?
Anyway I am impressed !
Tetris was one of the first GB game, if not the first.
It's not a very demanding game, that's why emulating it on a CPC is possible.
Gameboy processor is very close to Z80.
I "only" needed for tetris to add emulation support for 8 extra instructions not present in Z80.
It doesn't use "tricky" graphics rendering, the graphics emulation engine just fit this.
Also sound emulation is very basic.


Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 19:55, 18 September 20
Quote from: Skunkfish on 08:05, 18 September 20
It's really impressive indeed, I wonder if other games would be possible? I imagine Super Mario Land may struggle with the scrolling...?
It's possible because tetris is not a very demanding game.Keep in mind you have to render on the CPC at 60hz background graphics in 4 colors (160x144) + up to 40  8x8 sprites

Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 20:04, 18 September 20
Quote from: Xyphoe on 10:36, 18 September 20
A minor thing to report - got to the ending on Type A - the rocket ship taking off is quite glitchy and flickery. Not complaining, just reporting things as I find.
I'm absolutely loving this of course :)
I'm perfectly aware of how imperfect it is in the bonuses parts. I spent many time trying to fix it and find the best compromise.
In this part of the game, 40 sprites 8x8 need to be renderered. That's why it"s very slow on the CPC (major framerate drop ).
Fortunately, ingame only up to 12 sprites 8x8 are needed.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 20:25, 18 September 20
Quote from: TotO on 18:43, 18 September 20
Can we expect to have something like that? (very WIP theme)
I'll try if you can provide me with cpc palette data
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 20:27, 18 September 20
Quote from: 40Crisis on 20:25, 18 September 20
I'll try if you can provide me with cpc palette data
OK, I will give you that and a new palette too if you like it. :)


Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 20:43, 18 September 20
@40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951) : The idea is to use, if possible, a 256x224 screen area and a white border to fake the Game Boy bezel.

Theme 01 test:
- BORDER = 26
- INK 0 = 3
- INK 1 = 13
- INK 2 = 16
- INK 3 = 25

Theme 02 test:
- BORDER = 26
- INK 0 = 9
- INK 1 = 13
- INK 2 = 12
- INK 3 = 25

Theme 03 test:
- BORDER = 26
- INK 0 = 0
- INK 1 = 13
- INK 2 = 12
- INK 3 = 25
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: zeropolis79 on 21:46, 18 September 20
In theory, if it was renamed to the same filename required for the program, could other early Gameboy games be run on this program?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 21:56, 18 September 20
Quote from: zeropolis79 on 21:46, 18 September 20
In theory, if it was renamed to the same filename required for the program, could other early Gameboy games be run on this program?
The ROM is probably patched to get control over it. And no scrolling support, but Dr.Mario may be?  ;D
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: vasilisk on 22:02, 18 September 20
Do we save "with header" or "without header" ?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: XeNoMoRPH on 08:40, 19 September 20
https://youtu.be/LQfCg672t-U
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: pelrun on 09:01, 19 September 20
Quote from: vasilisk on 22:02, 18 September 20
Do we save "with header" or "without header" ?
You absolutely need the header, otherwise AMSDOS can't load it as a binary file.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 10:18, 19 September 20
Quote from: TotO on 20:43, 18 September 20
@40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951) : The idea is to use, if possible, a 256x224 screen area and a white border to fake the Game Boy marquee.

Theme 01 test:
- BORDER = 26
- INK 0 = 3
- INK 1 = 13
- INK 2 = 16
- INK 3 = 25

Theme 02 test:
- BORDER = 26
- INK 0 = 9
- INK 1 = 13
- INK 2 = 12
- INK 3 = 25

Theme 03 test:
- BORDER = 26
- INK 0 = 0
- INK 1 = 13
- INK 2 = 12
- INK 3 = 25

Test version - resolution changed to 256x224 + 3 sets of palette - Personally, I only like the theme03 because the others give "messy" menus
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 10:20, 19 September 20
Quote from: zeropolis79 on 21:46, 18 September 20
In theory, if it was renamed to the same filename required for the program, could other early Gameboy games be run on this program?
Sorry, no way
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: pelrun on 11:13, 19 September 20
Quote from: zeropolis79 on 21:46, 18 September 20
In theory, if it was renamed to the same filename required for the program, could other early Gameboy games be run on this program?
It's best not to think of this as emulation. It's more accurately a port, replacing the gameboy-specific code in the rom with CPC equivalents. It just happens to do it on the fly rather than being packaged as a pre-modified binary.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 11:38, 19 September 20
Quote from: 40Crisis on 10:18, 19 September 20
Test version - resolution changed to 256x224 + 3 sets of palette - Personally, I only like the theme03 because the others give "messy" menus
It seems less empty like that.
Thank you! ;D

Sure, the palettes tests are probably not the best choice. Sorry I will rethink about that!!!
Can we add few design things on the screen to improve the bezel visual?
(palette update for the colour strips, texts and rounded corners)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: zeropolis79 on 11:45, 19 September 20
Thanks - I've not had the chance to try it yet but I'll be trying it on my Plus this evening..
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Skunkfish on 17:27, 19 September 20
TotO, that marquee looks stunning! I hope 40Crisis has a chance to implement?  ;D
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 19:47, 19 September 20
Quote from: TotO on 11:38, 19 September 20
It seems less empty like that.
Thank you! ;D

Sure, the palettes tests are probably not the best choice. Sorry I will rethink about that!!!
Can we add few design things on the screen to improve the marquee visual?
(palette update for the colour strips, texts and rounded corners)
Toto, do you have the inlay in cpc format with palettes values ?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 19:50, 19 September 20
Quote from: 40Crisis on 19:47, 19 September 20
TotO, do you have the inlay in cpc format with palettes values ?
Sure, I can provide you what you want. (may be not today)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 19:52, 19 September 20
Quote from: TotO on 19:50, 19 September 20
Sure, I can provide you what you want. (may be not today)
Thanks
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: roudoudou on 09:50, 21 September 20
Hi @40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951) Can you tell us how the emulator works?
Thank you
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: norecess464 on 16:24, 21 September 20
Woaahh this reminds me the excitement I got when I discovered Syx/TotO's PacMan emulator few years ago..!

Splendid, I'm sincerely impressed.

Please, release a V2 with some (if not all..) of the improvements from TotO ! :)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 16:29, 21 September 20
Damn all the files I tried today failed... Is it so hard to find the correct ROM or was I just unlucky?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 18:49, 21 September 20
Quote from: Gryzor on 16:29, 21 September 20
Damn all the files I tried today failed... Is it so hard to find the correct ROM or was I just unlucky?
Did you add the Amsdos header?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 18:57, 21 September 20
Yes I did, I read all the instructions here...

But finally... all is well ;) And awesome!!!
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 19:49, 21 September 20
Quote from: roudoudou on 09:50, 21 September 20
Hi @40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951) Can you tell us how the emulator works?
Thank you
GB Hardware emulation is quite easy because I/O is done on the GB through memory registers (not ports).
A few rom traps are needed to render graphics, sound and input.GB Sharp LR35902  code is executed as is  on CPC Z80 because it's a modified Z80 with a few different instructions. 9 extra instructions not present in z80 are needed for emulating tetris.
They are emulated using the eight RST instructions available on the Z80. It takes me time to figure out how to do it without loosing too much speed. This is quite slow but does the job.
Graphics rendering is done on CPC by only displaying changing areas. Graphics are rendered asynchronously when there's enough time after the gameloop rendered at 60Hz. Average measured framerate is about 25 Hz ingame.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 19:54, 21 September 20
Quote from: norecess on 16:24, 21 September 20
Woaahh this reminds me the excitement I got when I discovered Syx/TotO's PacMan emulator few years ago..!

Splendid, I'm sincerely impressed.

Please, release a V2 with some (if not all..) of the improvements from TotO ! :)
Thanks for your nice feedback
I'll try to do my best to include improvements from TotO
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: SyX on 03:52, 22 September 20
Quote from: norecess on 16:24, 21 September 20
Woaahh this reminds me the excitement I got when I discovered Syx/TotO's PacMan emulator few years ago..!
Merci!!! :) You made my day happy... waiting for a really happy day when you release your next Mega Production ;)

And of course, AMAZING WORK @40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951)!!!  8) 8) 8)

I know that being Tetris a really famous game and after this wonderful result, this project will get you a lot of acclaim in the community, but you deserve that because along of the years you have brought to the CPC great classic games and I will play and enjoy them until your next project arrive. ¡Muchas Gracias!  ;)

Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: roudoudou on 07:57, 22 September 20
thank you for all explanations  8)
Quote from: 40Crisis on 19:49, 21 September 209 extra instructions not present in z80 are needed for emulating tetris.
They are emulated using the eight RST instructions available on the Z80.
ok so the emulator has to know where is the code and the data, it's not plug'n'play  ;D
with a little rework of the original code using those instructions, we may expect more native power
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 09:59, 22 September 20
OFF-TOPIC:

@40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951) : please fix your email address in your profile settings, all notification emails are bouncing back :)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 12:16, 22 September 20
Here a 4 colours 256x256 (16K) bezel picture. (PNG and BIN)
The areas match with a palette change using the Gate Array interrupts.
May be nice to use this format to allow peoples to provide their own "BEZEL.BIN" file.

CPC palettes:
- 9, 13, 12, 25
- 1, 13, 3, 26

PLUS palettes:
- 333, 777, 896, CDA
- 007, 777, 700, EEE
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 12:20, 22 September 20
In example, with the Amstrad CPC and Amstrad Plus palettes and rasters
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 12:28, 22 September 20
Never understood the appeal of running Gameboy have on a Big Screen with marquees until now 😁
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Joseman on 12:33, 22 September 20
Hi @40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951)

This isn't coding this is just MAGIC.

I always thought that porting small games from the gameboy was reasonably feasible on CPC.

I didn't know how and the explanation you give is really magic for my ears.

I have remembered my years with the gameboy with your port and it's exactly the same.

Congratulations!!

P.S. will you release the sourcecode for another people to port other games or do you think on make other ports?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: norecess464 on 12:41, 22 September 20
@40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951)  One small request: while CAPS LOCK key may be a good idea on real CPC keyboards, please can you also add another mapping for it (SHIFT, CONTROL..) ? Many people will probably run the game through an emulator, and the CAPS LOCK key is absolutely not convenient for that purpose on PC keyboard.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Longshot on 09:57, 23 September 20
@40Crisis (https://www.cpcwiki.eu/forum/profile/?u=951)You did work on a very interesting subject.
Bravo for this achievement!  ;)

I am amazed to see that there are no ld (a16),hl and ld hl,(a16) instructions on LR35902 processor.
The replacement for ld (hl-),a and ld a,(hl-) is delicate since they replace instructions that already exist with other opcodes (ld a,(a16)/ld (a16),a)

If I could make a few remarks:

You forgot to remove one ld (hl),a from the routine that patches the memory with bytes, just before running the rom. (thus doubling ld (hl),a)
(a remainder of the copy/paste routine that patches the memory with words)

You don't need to use DI at the begining of your interrupt routine (called in vectorized mode under IM2 mode)
No other interrupt can occur until the ei/ret (reti not needed)

I think you can improve the swap a and swap e instructions, which you simulate with the rst38h instruction by setting the Carry Flag
For swap a (cb 37), I think you can just do rrca/rrca/rrca/rrca
For swap e (cb 33), I think you can just do rrc e/rrc e/rrc e/rrc e
For this latter instruction, which you patch once at 6db0 in the ROM, I think there is a bug:
ld e, a
exx
ex af, af '
ret


instead of
exx
ld e, a
ex af, af '
ret


Can you tell us more about the management of the graphical interface?
Do you have a unique periodic rendering routine for data generated by the GB in its IO space?
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 19:23, 23 September 20
Quote from: Longshot on 09:57, 23 September 20
@40Crisis (https://www.cpcwiki.eu/forum/profile/?u=951)You did work on a very interesting subject.
Bravo for this achievement!  ;)

It's an honor to have a CPC Legend commenting my project

I am amazed to see that there are no ld (a16),hl and ld hl,(a16) instructions on LR35902 processor.
The replacement for ld (hl-),a and ld a,(hl-) is delicate since they replace instructions that already exist with other opcodes (ld a,(a16)/ld (a16),a)I was aware of this problem and replacement needs to be done in a particular order
If I could make a few remarks:

You forgot to remove one ld (hl),a from the routine that patches the memory with bytes, just before running the rom. (thus doubling ld (hl),a)
(a remainder of the copy/paste routine that patches the memory with words)
You're right copy and paste is not a good habit when coding but so convenient

You don't need to use DI at the begining of your interrupt routine (called in vectorized mode under IM2 mode)
No other interrupt can occur until the ei/ret (reti not needed)Thanks for the info, will try it
I think you can improve the swap a and swap e instructions, which you simulate with the rst38h instruction by setting the Carry Flag
For swap a (cb 37), I think you can just do rrca/rrca/rrca/rrca
For swap e (cb 33), I think you can just do rrc e/rrc e/rrc e/rrc eMuch more clever and efficient that the one I wrote
For this latter instruction, which you patch once at 6db0 in the ROM, I think there is a bug:ld e, a
exx
ex af, af '
ret


instead of
exx
ld e, a
ex af, af '
ret

You're absoluty right about the bug, what a good sight you have

Can you tell us more about the management of the graphical interface?
Do you have a unique periodic rendering routine for data generated by the GB in its IO space?
Yes there's one rendering routine fo background titles and one for the sprites ( splitted in 8 multiple aligned or not)

Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 19:25, 23 September 20
Quote from: norecess on 12:41, 22 September 20
@40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951)  One small request: while CAPS LOCK key may be a good idea on real CPC keyboards, please can you also add another mapping for it (SHIFT, CONTROL..) ? Many people will probably run the game through an emulator, and the CAPS LOCK key is absolutely not convenient for that purpose on PC keyboard.
Very good suggestion

LEFT SHIFT will be as TAB and CONTROL the same as CAPS if you agree in the next release.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 19:30, 23 September 20
Quote from: Joseman on 12:33, 22 September 20
Hi @40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951)

This isn't coding this is just MAGIC.

I always thought that porting small games from the gameboy was reasonably feasible on CPC.

I didn't know how and the explanation you give is really magic for my ears.

I have remembered my years with the gameboy with your port and it's exactly the same.

Congratulations!!

P.S. will you release the sourcecode for another people to port other games or do you think on make other ports?
I don't plan to release source code.
Anyway, I believe the emulator was possible because tetris is a simple game with few things displayed.
In my opinion, the CPC is not powerful enough to emulate GB 4,19MHZ processor plus 60Hz display rendering (background tiles 160x144 plus up to 40 8x8 four color sprites).
To give you an idea the emulator ingame (maximum 12 sprites 8x8 are displayed) has a average speed of 25 fps.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Khomenor on 12:08, 24 September 20
Quote from: Redbug on 15:05, 18 September 20
Ok..
You break the game :(
My port seems so.... a waste of time...


https://www.facebook.com/redbug/videos/10158439917016668/?t=3 (https://www.facebook.com/redbug/videos/10158439917016668/?t=3)
Your port is not a waste of time, You made a port, 40crisis made an emulator :)
As I said in Oncle_ced's stream I like your port, not the music. Just not my kind of remix  ;)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 12:28, 24 September 20
Indeed I love both for different reasons...
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Longshot on 17:23, 24 September 20
Oups...Better like this to take care of the carry flag... ;D
For swap a (cb 37), rrca/rrca/rrca/rrca/ccf
For swap e (cb 33), rrc e/rrc e/rrc e/rrc e/ccf

In the graphics engine, you can save cpu and code as well.
To calculate the address of the tile
19 usec, 10 bytes
        ld h,0
        ld l,a               
        add hl,hl       
        add hl,hl
        add hl,hl
        add hl,hl
        ld a,#80           
        or h
        ld h,a
You can simplify it by doing ld h,8 instead of ld h,0 and deleting ld a,#80...
But you can also do that
    15 usec, 10 bytes
    ld hl,bonneteau+1
    ld (hl),a
    ld a,#80
    rld
bonneteau ld l,0
    ld h,a

or this
    15 usec, 15 bytes   
    ld h,8
    add a,a
    rl h
    add a,a
    rl h
    add a,a
    rl h
    add a,a
    rl h
    ld l,a

When updating the screen, for each         
         ldi
        ldi
        dec e
        dec e

replace dec e by ld e,b
at the end of one tile, replace         
         exx
        ld d,c
        ld e,b
        inc e
        inc e
        exx


by this       
        exx
        ld d,c
        exx
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 21:35, 25 September 20
Quote from: Longshot on 17:23, 24 September 20
Oups...Better like this to take care of the carry flag... ;D
For swap a (cb 37), rrca/rrca/rrca/rrca/ccf
For swap e (cb 33), rrc e/rrc e/rrc e/rrc e/ccf

In the graphics engine, you can save cpu and code as well.
To calculate the address of the tile
23 usec, 10 bytes
        ld h,0
        ld l,a               
        add hl,hl       
        add hl,hl
        add hl,hl
        add hl,hl
        ld a,#80           
        or h
        ld h,a
You can simplify it by doing ld h,8 instead of ld h,0 and deleting ld a,#80...
But you can also do that
    15 usec, 10 bytes
    ld hl,bonneteau+1
    ld (hl),a
    ld a,#80
    rld
bonneteau ld l,0
    ld h,a

or this
    15 usec, 15 bytes   
    ld h,8
    add a,a
    rl h
    add a,a
    rl h
    add a,a
    rl h
    add a,a
    rl h
    ld l,a

When updating the screen, for each         
         ldi
        ldi
        dec e
        dec e

replace dec e by ld e,b
at the end of one tile, replace         
         exx
        ld d,c
        ld e,b
        inc e
        inc e
        exx


by this       
        exx
        ld d,c
        exx

Master class of z80 programming by Longshot ! Thank you. Optimisations will be included in next update to come
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 16:07, 26 September 20
New version 1.1
What's new- added gb inlay  + cpc palette and cpc+ palette from totO: many thanks to him
- emulator can be now run in two flavour:run"temu" for cpcrun'temuplus" for cpc+
- some bug fixes and code optimisation thanks to Longshot
- two new keys left shift and left control same as tab and CAPS LOCK suggested by Norecess
- You can edit main palette for cpc and cpc plus in basic loader see line 210 and more
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 16:39, 26 September 20
Amazing work!!!  8)

Here, some WIP theme for CPC if you can't wait.
Just update the BASIC with the colours codes on the top of your floppy drive hardware values.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 17:44, 26 September 20
Quote from: TotO on 16:39, 26 September 20
Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
« Reply #72 on: Today at 18:39 »

    Like
    Quote
If you intend to customize palette, you will need the CPC hardware value:


reference here: https://www.cpcwiki.eu/index.php/CPC_Palette

Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: vasilisk on 20:09, 26 September 20
Looks much better on real cpc. Sorry for the poor capture. My phone is not good for video recording 50fps. :)


https://youtu.be/fFqsJg7eHus (https://youtu.be/fFqsJg7eHus)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Joseman on 21:07, 26 September 20
Hi!
Much better now with the marquee!!

One thing, someone noticed sound glitches with the music? like random notes played sometimes... in the 1.0 version i think that didn't hear that random notes...
I'm loading the game with M4 but the load has to be perfect because it doesn't invade sensible memory...
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 22:15, 26 September 20
version 1.1a
9 new CPC palettes from TotO added
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 22:18, 26 September 20
Quote from: Joseman on 21:07, 26 September 20
Hi!
Much better now with the marquee!!

One thing, someone noticed sound glitches with the music? like random notes played sometimes... in the 1.0 version i think that didn't hear that random notes...
I'm loading the game with M4 but the load has to be perfect because it doesn't invade sensible memory...
What CPC model  do you have ?
As far as I'm concerned no changes in the sound emulation
The main change between v1.1 and v1.0 is adding palette changes through interrupts (done twice per 50Hz)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: megachur on 04:55, 27 September 20
Quote from: 40Crisis on 22:15, 26 September 20
version 1.1a
9 new CPC palettes from TotO added
Congratulations 40Crisis and TotO : with the gfx and code improvements, it is far better and close to the original !!!

what about improving the sound too... it don't sound exactly the same as a GameBoy and need an AY8912 CPC adaptation to be better and your adaptation will be very close of the original !
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: TotO on 08:08, 27 September 20
Quote from: megachur on 04:55, 27 September 20what about improving the sound too... it don't sound exactly the same as a GameBoy and need an AY8912 CPC adaptation to be better and your adaptation will be very close of the original !
The inlay is not a part of the GameBoy emulation. The sound is emulated, based on a frequency conversion. It will require a straight way to convert sound envelopes from one machine to another. (IMHO, not an AY adaptation)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Joseman on 11:04, 27 September 20
Quote from: 40Crisis on 22:18, 26 September 20What CPC model  do you have ?
As far as I'm concerned no changes in the sound emulation
The main change between v1.1 and v1.0 is adding palette changes through interrupts (done twice per 50Hz)

Hi, it's a classic cpc6128 with memory expansion and M4. Maybe i did anything bad on transfer. I'll try today again.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Khomenor on 19:38, 27 September 20
I think I will show your emu in my next stream, The world need to know! ;D
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 00WReX on 10:42, 28 September 20
 :)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 11:40, 28 September 20
That's a beauty!
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: norecess464 on 03:11, 29 September 20
I just tested the last version on my Amstrad Plus .. congratulations, the new visuals are fantastic !! it really feels like a GameBoy.

My only remaining complain now would be about the audio part. Clearly, the music has some glitches, but I guess it would be complicated to fix..
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Novabug on 22:37, 06 October 20
For some reason, v1 or V1.1 don't run in any of my 464's with original DK'Tronics 64k expansion. Bank test seems fine, and it loads fully, but crashes instantly.


Anyway, it does run perfectly on my 6128... sooo.... I made this as a celebration....



Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: zeropolis79 on 22:53, 06 October 20
Great cover Chris!
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Novabug on 00:26, 08 October 20
And a cassette label
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: norecess464 on 14:09, 08 October 20
Quote from: Novabug on 00:26, 08 October 20
And a cassette label

Woahhhh... really, I'm not into tape-based Amstrads.... but I love this thing  :o
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: CraigsBar on 17:27, 18 October 20
Quote from: Novabug on 22:37, 06 October 20
For some reason, v1 or V1.1 don't run in any of my 464's with original DK'Tronics 64k expansion. Bank test seems fine, and it loads fully, but crashes instantly.


Anyway, it does run perfectly on my 6128... sooo.... I made this as a celebration....


I can confirm this. ALthough it runs fine on an expanded 464plus (internal 128k) it does NOT work on a CPC 464 with a modern Ram Expansion either. I have 2 CPC 464's one with basic 1.1 (from a 664) and one with basic 1.0. Both exhibit the same crash as Chris is reporting.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 00WReX on 05:47, 19 October 20
Quote from: CraigsBar on 17:27, 18 October 20

I can confirm this. ALthough it runs fine on an expanded 464plus (internal 128k) it does NOT work on a CPC 464 with a modern Ram Expansion either. I have 2 CPC 464's one with basic 1.1 (from a 664) and one with basic 1.0. Both exhibit the same crash as Chris is reporting.

Interesting...as in my pictures above, it works on my 464 with M4 and Xmem.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: CraigsBar on 18:16, 19 October 20
Quote from: 00WReX on 05:47, 19 October 20
Interesting...as in my pictures above, it works on my 464 with M4 and Xmem.


OK Further testing to try and get to the bottom of this.


Used a CPC 6128 lower/Basic rom (40025) in a Lower rom board, Loaded from tape -  Same issue
Used an M4 with the default setup, Loaded from tape -  Same issue


Repeated the above with loading from DSK (in a gotek) - same issue
Repeated again loading from the M4 SD card directly (Using the DSK file) - Same issue


all these images work perfectly on my CPC 6128, 6128plus and 4128plus. However they just do not want to play ball on a memory expanded CPC 464.


Any thoughts @40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951) ? I'd love to get it working from tape on my CPC 464's at the moment I have made a tape of this production and can only use it (Without additional hardware) on the 4128plus ;)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: andycadley on 19:22, 19 October 20
What RAM banking configuration does it use? Some older memory expansions don't support them all. Even the ones that do have some limitations on the 464 only in the C3 configuration if the upper ROM is active, which is a fundamental limitation of the machine and can't be bypassed (as far as I recall)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Xyphoe on 20:07, 19 October 20
You may spot a lot of guests currently viewing this topic!
I made a video on this today -
https://www.youtube.com/watch?v=WWid7Qp-eYs (https://www.youtube.com/watch?v=WWid7Qp-eYs)
Damn the timing though! I hope there's a fix for some of you with 464's and memory expansions soon.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 20:23, 19 October 20
Quote from: CraigsBar on 18:16, 19 October 20

OK Further testing to try and get to the bottom of this.


Used a CPC 6128 lower/Basic rom (40025) in a Lower rom board, Loaded from tape -  Same issue
Used an M4 with the default setup, Loaded from tape -  Same issue


Repeated the above with loading from DSK (in a gotek) - same issue
Repeated again loading from the M4 SD card directly (Using the DSK file) - Same issue


all these images work perfectly on my CPC 6128, 6128plus and 4128plus. However they just do not want to play ball on a memory expanded CPC 464.


Any thoughts @40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951) ? I'd love to get it working from tape on my CPC 464's at the moment I have made a tape of this production and can only use it (Without additional hardware) on the 4128plus ;)



Any thoughts @40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951) ? I'd love to get it working from tape on my CPC 464's at the moment I have made a tape of this production and can only use it (Without additional hardware) on the 4128plus ;)

Emulator make use of the following memory gate array configuration:
$C0  standard 64k=bank 0,1,2,3
$C1 => bank 7 at $C000
$C4 => bank 4 at $4000
$C5 => bank 5 at $4000
see http://www.norecess.net/advancedmemoryusage.html (http://www.norecess.net/advancedmemoryusage.html) for explanations
When you say, it crashed:Does the CPC resets ?
Is there someone visible apart from blank white screen ?
Is so, could you provide me whith a capture ?I don't think it could be related with roms.
Maybe an emulator emulating dk'tronics memory might reproduce the problem ?

Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: CraigsBar on 21:31, 19 October 20
Hi @40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951) ,


Yes the game loads. the Marquee / Bezel is displayed. and then the colours go pearshaped (sometimes there is screen artifacts / corruption) and the machine locks up.


Loaded from the same media (Either DSK or physical tape) on both my CPC 6128's work fine, My 6128plus and My 4128plus both work fine Both CPC 464's with any of the following memory expansions Toto Xmem, Toto Zmem, Piotr DDI4 always the same, always crash. after displaying the bezel.


My 2 CPC 464's are different revisions, the first is a tall key early board (CTRC 0). the other one is a final cost down Pre Asic (CTRC 4) so they top and tail the production run.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 21:55, 19 October 20
Quote from: CraigsBar on 21:31, 19 October 20
Hi @40Crisis (https://www.cpcwiki.eu/forum/index.php?action=profile;u=951) ,


Yes the game loads. the Marquee / Bezel is displayed. and then the colours go pearshaped (sometimes there is screen artifacts / corruption) and the machine locks up.


Loaded from the same media (Either DSK or physical tape) on both my CPC 6128's work fine, My 6128plus and My 4128plus both work fine Both CPC 464's with any of the following memory expansions Toto Xmem, Toto Zmem, Piotr DDI4 always the same, always crash. after displaying the bezel.


My 2 CPC 464's are different revisions, the first is a tall key early board (CTRC 0). the other one is a final cost down Pre Asic (CTRC 4) so they top and tail the production run.
If you can do a video capture from your smartphone for example and Private Mail Me the link to it, It would be very useful to try to guess where is the problem.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: 40Crisis on 22:00, 19 October 20
Quote from: Xyphoe on 20:07, 19 October 20
You may spot a lot of guests currently viewing this topic!
I made a video on this today -
https://www.youtube.com/watch?v=WWid7Qp-eYs (https://www.youtube.com/watch?v=WWid7Qp-eYs)
Damn the timing though! I hope there's a fix for some of you with 464's and memory expansions soon.
Very nice and fair review. Please note that you are still allowed to cycle between CPC palettes using the "0" key, in version 1.1a
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Xyphoe on 10:56, 20 October 20
Quote from: 40Crisis on 22:00, 19 October 20
Very nice and fair review. Please note that you are still allowed to cycle between CPC palettes using the "0" key, in version 1.1a
Yea :( I got it working now, but weirdly when making this it wasn't working - I tried several times. Now that's stuck in the final video and can't be changed... grrrrr. I'm sorry. I can only put it down to an emulator glitch.
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: xenon on 15:30, 21 October 20
That's outstanding!! Thanks very much for your work!  :)
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: remax on 22:01, 29 November 20
Great work !


I'm a daily player of GB Tetris and i must say that the fidelity is really good.


Only two caveats :


* The sound is less bearable than on the GB
* It's less convenient to take a CPC with me in the place where i play tetris usually  ;D
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: Gryzor on 10:06, 30 November 20
"less bearable" :D :D
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: villain on 11:34, 30 November 20
Quote from: remax on 22:01, 29 November 20

* It's less convenient to take a CPC with me in the place where i play tetris usually  ;D


No pictures, please!!!  :laugh:
Title: Re: GB TETRIS EMULATOR TEMU FOR AMSTRAD CPC 6128(+)
Post by: remax on 19:17, 30 November 20
Quote from: villain on 11:34, 30 November 20

No pictures, please!!!  :laugh:


Don't worry, i don't usually take pictures there  ::)


Quote from: Gryzor on 10:06, 30 November 20"less bearable" :D :D


I couldn't think of anything which would fit better  :D
Powered by SMFPacks Menu Editor Mod