Skip to content

Commit

Permalink
Fix Sprites bugs with MSX1 Machines
Browse files Browse the repository at this point in the history
  • Loading branch information
ericb59 committed Nov 10, 2020
1 parent a500c76 commit 184582a
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 37 deletions.
Binary file added Working Folder/.DS_Store
Binary file not shown.
Binary file added Working Folder/fusion-c/.DS_Store
Binary file not shown.
Binary file modified Working Folder/fusion-c/lib/fusion.lib
100755 → 100644
Binary file not shown.
Binary file added Working Folder/fusion-c/source/.DS_Store
Binary file not shown.
Binary file modified Working Folder/fusion-c/source/lib/fusion.lib
Binary file not shown.
7 changes: 2 additions & 5 deletions Working Folder/fusion-c/source/lib/setspritepattern.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| |_| \__,_|___/_|\___/|_| |_| * |
| |
| The MSX C Library for SDCC |
| V1.2 - 08 2019 |
| V1.2 - 08 2019 Updated 11/9/2020 |
| |
| Eric Boez & Fernando Garcia |
| |
Expand Down Expand Up @@ -37,9 +37,6 @@
/* set sprite pattern */
/* --------------------------------------------------------- */
void SetSpritePattern( char pattern_no, char* p_pattern, char s_size ) {
DisableInterrupt();
VpokeFirst( Peekw( PATBAS ) + (pattern_no << 3) );
OutPorts( 0x98, p_pattern, s_size );
EnableInterrupt();
CopyRamToVram(p_pattern, Peekw( 0xF926 ) + (pattern_no << 3), s_size);
}

38 changes: 26 additions & 12 deletions Working Folder/fusion-c/source/lib/spriteoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,33 @@
| |
\___________________________________________________________/
*/
/* sprite16
| Activate Sprite data size 16x16 pixels
| 2006/11/25 t.hara
| 2018 Eric Boez
/* spriteOff
| 2018 Eric Boez Updated November 2020
*/
#include "../../header/msx_fusion.h"

#define RG08SAV 0xFFE7

void SpriteOff(void)
void SpriteOff(void) __naked
{
unsigned char val;
val=Peek(RG08SAV) | 0b00000010;
VDPwriteNi(0x08,val); /// Write to VDP Register 8
Poke(RG08SAV,val);
__asm

RG1SAV = 0xF3E0
DPPAGE = 0xFAF5
ATRBAS = 0xF928
RG25SAV = 0xFFFA
RG2SAV = 0xF3E1
RG8SAV = 0xFFE7
RG9SAV = 0xFFE8

push ix
ld a,(RG8SAV)
or #0b00000010
ld (RG8SAV),a
ld b,a
ld c,#8
ld ix,#0x0047 ; Write VDP Bios
ld iy, (0xFCC0) ; mainrom slotaddress
call 0x001c ; interslotcall
ei
pop ix
ret
__endasm;
}
37 changes: 26 additions & 11 deletions Working Folder/fusion-c/source/lib/spriteon.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,34 @@
| |
\___________________________________________________________/
*/
/* sprite16
| Activate Sprite data size 16x16 pixels
| 2006/11/25 t.hara
| 2018 Eric Boez
/* spriteOn
| 2018 Eric Boez Updated November 2020
*/
#include "../../header/msx_fusion.h"

#define RG08SAV 0xFFE7

void SpriteOn(void)
void SpriteOn(void) __naked
{
unsigned char val;
val=Peek(RG08SAV) & 0b11111101;
VDPwriteNi(0x08,val); /// Write to VDP Register 8
Poke(RG08SAV,val);
__asm
RG1SAV = 0xF3E0
DPPAGE = 0xFAF5
ATRBAS = 0xF928
RG25SAV = 0xFFFA
RG2SAV = 0xF3E1
RG8SAV = 0xFFE7
RG9SAV = 0xFFE8

push ix
ld a,(RG8SAV)
and #0b11111101
ld (RG8SAV),a
ld b,a
ld c,#8
ld ix,#0x0047 ; Write VDP Bios
ld iy, (0xFCC0) ; mainrom slotaddress
call 0x001c ; interslotcall
ei
pop ix
ret
__endasm;

}
59 changes: 51 additions & 8 deletions Working Folder/fusion-c/source/lib/vram.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
;| |_| \__,_|___/_|\___/|_| |_| * |
;| |
;| The MSX C Library for SDCC |
;| V1.1 - 05-2019 |
;| V1.1 - 05-2019 updated 11/09/20 |
;| |
;| Eric Boez & Fernando Garcia |
;| |
Expand All @@ -33,6 +33,7 @@ EXBRSA = 0xFAF8
SCRMOD = 0xFCAF
ACPAGE = 0xFAF6
MODE = 0xFAFC
ATRBAS = 0xF928

;---------------------------
; Return the VRAM Size of the MSX Computer 16/64/128 KB
Expand All @@ -51,17 +52,15 @@ _GetVramSize::
ret

;---------------------------


; MODULE LDIRVM
;
; LDIRVM moves block from memory to the VRAM.
;
; efinition : CopyRamToVram(void *SrcRamAddress, unsigned int DestVramAddress, unsigned int Length);
; Definition : CopyRamToVram(void *SrcRamAddress, unsigned int DestVramAddress, unsigned int Length);
;
_CopyRamToVram::
push ix

di
ld ix,#0
add ix,sp
ld E,4(ix) ; SRC RAM address
Expand Down Expand Up @@ -89,6 +88,7 @@ ldirvm_1:
jp nz,ldirvm_1
dec a
jp nz,ldirvm_1
ei
pop ix
ret

Expand All @@ -102,7 +102,7 @@ ldirvm_1:

_CopyVramToRam::
push ix

di
ld ix,#0
add ix,sp
ld E,4(ix) ; SRC VRAM address
Expand Down Expand Up @@ -130,6 +130,7 @@ ldirmv_1:
jp nz,ldirmv_1
dec a
jp nz,ldirmv_1
ei
pop ix
ret

Expand Down Expand Up @@ -201,7 +202,49 @@ set_high:
setaddress_1:
di
out (c),l ; set the low address
ld a,h ; prepare to set the middle address
ld a,h ; prepare to set the middle address
and #0b00111111
pop de
ret
ret

;----------------------------
; MODULE PUTSPRITE
;
; PutSprite ( char sprite_no, char pattern_no, char x, char y, char ec_color );
;
;

_PutSprite::
push ix
ld ix,#0
add ix,sp
ld a,4(ix) ; sprite_no
rlca
rlca
ld hl,(ATRBAS)
; add HL to A
add a,l
ld l,a
adc a,h
sub l
ld h,a
di

call SETWRT
di
ld c,#0x98
ld a, 7 (ix) ; y
out (c),a

ld a, 6 (ix) ; x
out (c),a

ld a, 5 (ix) ; pattern_no
out (c),a

ld a, 8 (ix) ; ec_color
out (c),a
ei
pop ix

ret
26 changes: 25 additions & 1 deletion history.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@

—————————————————— 2020 - November ——————————————————
Fusion-C 1.2b
Fix Sprites Bug with MSX1 machines

—————————————————— 2019 - October ——————————————————
Fusion-C 1.2a

added function to library and to manual/book :
SetSC5ColorPalette
SC2BoxFill
SetVDPWrite
SetVDPRead

- Fixed error or rewritten functions :
SC2Pset (New fast Pset routine for screen 2)
SC2Circle & SC2CircleFilled Definitions fixed
SetSpritePattern, MSX1 VDP fixed. + Faster routine
PutSprite, MSX1 VDP Fixed. + Faster routine
Vpoke & Vpeek, MSX1 VDP Fixed


Added Example :
sc5ColorBlink.c

—————————————————— 2019 - August 14 ——————————————————
FUSION-c 1.2
FUSION-C 1.2
Changes :

- added support of GFX9000/V990 and TCPIP for the Gr8NET. Both in beta version
Expand Down

0 comments on commit 184582a

Please sign in to comment.