Autor
| Is there any C cross compiler that generates ROM files?
| Huey msx professional Mensajes: 671 | Publicado: Abril 11 2006, 18:33   | Hmmmm, I see. I'm gonna try an article I found that uses R#14 and #15
| | ARTRAG msx master Mensajes: 1802 | Publicado: Abril 11 2006, 18:36   | | | ARTRAG msx master Mensajes: 1802 | Publicado: Abril 11 2006, 18:37   | Do you have tryed my code?
Do you see a sprite cycling all around the screen?
| | Huey msx professional Mensajes: 671 | Publicado: Abril 11 2006, 18:43   | Quote:
| Do you have tryed my code?
Do you see a sprite cycling all around the screen?
|
I missed it. I'll Try it | | ARTRAG msx master Mensajes: 1802 | Publicado: Abril 11 2006, 18:45   | The source posted @ April 11 2006, 12:34
| | Huey msx professional Mensajes: 671 | Publicado: Abril 11 2006, 18:55   | Duh 
It works. Thanks
Works over so i'll be of home... I will check the compression link (cannot download it at work). | | ARTRAG msx master Mensajes: 1802 | Publicado: Abril 11 2006, 22:25   | This code reads the cursors and the spacebar.
Use them to control the sprite.
/*
* Project Hunter for MSX1 16kb ROM
*/
#include <stdlib.h>
#include <intrpt.h>
/*
* DEFINITIONS
*/
#define u_int unsigned int
#define u_char unsigned char
#define u_short unsigned short
#define bool char
#define true 1
#define false 0
/*
* SCREEN 2 DEFINITIONS HARDCODED
*/
#define PNT 0x1800 // Pattern Name Table
#define PGT 0x0000 // Pattern Generator Table
#define PCT 0x2000 // Pattern Color Table
#define SAT 0x1b00 // Sprite Attribute Table
#define SPT 0x3800 // Sprite Pattern Table
// ROM Header
#asm
romheader:
psect vectors
defb 'A','B'
defw _main
defb 0,0,0,0,0,0
defb 0,0,0,0,0,0
truestart:
#endasm
/*
* PORT mappings
*/
static port u_char v99 @ 0x99; // VDP: Command and status register
static port u_char v98 @ 0x98; // VDP: Video RAM data
static port u_char va2 @ 0xa2; // PSG: Data read
static port u_char va1 @ 0xa1; // PSG: Data write
static port u_char va0 @ 0xa0; // PSG: Address latch
extern u_char back1[8];
extern u_char back1_color[8];
extern u_char vdpregs[8];
/*
* VPD functions
*/
void init_vpd(u_char *source) {
u_char x=8;
di();
for (; x > 0; x--) {
v99 = *source++;
v99 = (8-x) | 128;
}
ei();
}
void vwrite(u_short count, u_char *source, u_short addr) {
di();
v99 = addr & 255;
v99 = (addr>>8) | 64;
ei();
for (;count > 0;count--){
v98 = *source++;
}
}
void vfill(u_short count, u_char value, u_short addr) {
di();
v99 = addr & 255;
v99 = (addr>>8) | 64;
ei();
for (;count > 0;count--){
v98 = value;
}
}
u_char checkkbd(u_char kbdline)
{
#asm
; checkkbd: ckeck keyboard line
; syntax:checkkbd <keyboar line #>
; in: e
; out: l
;
; i8255 ports
;
i8255porta equ 0a8h ; slot selection
i8255portb equ 0a9h ; keyboard column input
i8255portc equ 0aah ; leds, motor, cassette, kbd line
i8255portd equ 0abh ; mode select for i8255 ports A,B,C
in a,(i8255portc)
and 011110000B ; upper 4 bits contain info topreserve
or e
out (i8255portc),a
in a,(i8255portb)
ld l,a
#endasm
}
main()
{
u_int t;
u_char room[768];
u_char sprt[] = {100,124,0,15};
init_vpd(vdpregs);
for (t=0;t < 768; t++) {
room[t]= 255-(t&255);
}
vfill(256*8*3, 0xf5, PCT);
vwrite(8, back1, PGT);
vwrite(8, back1_color, PCT);
vwrite(768, room, PNT);
vwrite(8, back1,SPT);
while(1) {
asm("halt");
vwrite(4, sprt,SAT);
sprt[0] += ((checkkbd(8) & 32) !=0)-((checkkbd(8) & 64) !=0);
sprt[1] += ((checkkbd(8) & 16) !=0)-((checkkbd(8) & 128) !=0);
sprt[3] = (sprt[3] + ((checkkbd(8) & 1)!=0)) & 15;
}
}
// Data segement
#asm
psect data
global _vdpregs
_vdpregs:
defb 0x02 // Reg# 0 000000[M3][EV]
defb 0x60 // Reg# 1 [4/16k][BLANK][IE][M1][M2]0[SIZE][MAG]
defb 0x06 // Reg# 2 0000[NAME TABLE BASE ADDRESS] = 3C00h
defb 0xff // Reg# 3 [COLOR BASE ADDRESS] 3000h
defb 0x03 // Reg# 4 00000[PATTERN GENERATOR BASE ADDRESS] 1800h
defb 0x36 // Reg# 5 0[SPRITE ATTRIBUTE TABLE BASE ADDRESS] 3C80h
defb 0x07 // Reg# 6 00000[SPRITE PTRN GNRTR BASE ADDRESS] 3800h
defb 0x01 // Reg# 7 [TEXT COLOR 4bts][BACKDROP COLOR 4bts]
global _back1
_back1:
defb 00011100B
defb 00110110B
defb 11000011B
defb 11010011B
defb 11001011B
defb 11000011B
defb 01100110B
defb 00111100B
global _back1_color
_back1_color:
defb 00001111B
defb 00001111B
defb 00001111B
defb 00001111B
defb 00001111B
defb 00001111B
defb 00001111B
defb 00001111B
pad:
defs 0xbfff-0x8278 // substitute each time with the address of "pad" from the .sym file
defb 01
#endasm
| | ARTRAG msx master Mensajes: 1802 | Publicado: Abril 12 2006, 00:54   | Look at this simple 8 directional scroll with sprite movements
/*
* Project Hunter for MSX1 16kb ROM
*/
#include <stdlib.h>
#include <intrpt.h>
/*
* DEFINITIONS
*/
#define u_int unsigned int
#define u_char unsigned char
#define u_short unsigned short
#define bool char
#define true 1
#define false 0
/*
* SCREEN 2 DEFINITIONS HARDCODED
*/
#define PNT 0x1800 // Pattern Name Table
#define PGT 0x0000 // Pattern Generator Table
#define PCT 0x2000 // Pattern Color Table
#define SAT 0x1b00 // Sprite Attribute Table
#define SPT 0x3800 // Sprite Pattern Table
// ROM Header
#asm
romheader:
psect vectors
defb 'A','B'
defw _main
defb 0,0,0,0,0,0
defb 0,0,0,0,0,0
truestart:
#endasm
/*
* PORT mappings
*/
static port u_char v99 @ 0x99; // VDP: Command and status register
static port u_char v98 @ 0x98; // VDP: Video RAM data
static port u_char va2 @ 0xa2; // PSG: Data read
static port u_char va1 @ 0xa1; // PSG: Data write
static port u_char va0 @ 0xa0; // PSG: Address latch
extern u_char back1[8];
extern u_char back1_color[8];
extern u_char vdpregs[8];
/*
* VPD functions
*/
void init_vpd(u_char *source) {
u_char x=8;
di();
for (; x > 0; x--) {
v99 = *source++;
v99 = (8-x) | 128;
}
ei();
}
void vwrite(u_short count, u_char *source, u_short addr) {
di();
v99 = addr & 255;
v99 = (addr>>8) | 64;
ei();
for (;count > 0;count--){
v98 = *source++;
}
}
void vfill(u_short count, u_char value, u_short addr) {
di();
v99 = addr & 255;
v99 = (addr>>8) | 64;
ei();
for (;count > 0;count--){
v98 = value;
}
}
u_char checkkbd(u_char kbdline)
{
#asm
; checkkbd: ckeck keyboard line
; syntax:checkkbd <keyboar line #>
; in: e
; out: l
;
; i8255 ports
;
i8255porta equ 0a8h ; slot selection
i8255portb equ 0a9h ; keyboard column input
i8255portc equ 0aah ; leds, motor, cassette, kbd line
i8255portd equ 0abh ; mode select for i8255 ports A,B,C
in a,(i8255portc)
and 011110000B ; upper 4 bits contain info topreserve
or e
out (i8255portc),a
in a,(i8255portb)
ld l,
#endasm
}
#define map_w 4*32
#define map_h 2*24
void vscreen(u_char * addr) {
di();
v99 = PNT & 255;
v99 = (PNT>>8) | 64;
ei();
#asm
ex de,hl
ld c,0x98
ld de,map_w-32
rept 24
ld b,0x20
otir
add hl,de
endm
#endasm
}
main()
{
u_int t;
u_char room[map_w*map_h];
u_char sprt[] = {100,124,0,15};
u_char *window = room;
init_vpd(vdpregs);
for (t=0;t < map_w*map_h; t++) {
room[t]= (t&255);
}
vfill(256*8*3, 0xf5, PCT);
vwrite(256*8, 0x1bbf, PGT);
vwrite(256*8, 0x1bbf, PGT+256*8);
vwrite(256*8, 0x1bbf, PGT+256*8*2);
vwrite(8, back1, PGT);
vwrite(8, back1_color, PCT);
vwrite(8, back1,SPT);
while(1) {
u_char kbd = checkkbd(8);
asm("halt");
vscreen(window);
vwrite(4, sprt,SAT);
sprt[0] += ((kbd & 32) !=0)-((kbd & 64) !=0);
sprt[1] += ((kbd & 16) !=0)-((kbd & 128) !=0);
sprt[3] = (sprt[3] + ((kbd & 1)!=0)) & 15;
window += ((kbd & 16) !=0)-((kbd & 128) !=0);
window += (((kbd & 32) !=0)-((kbd & 64) !=0))*map_w;
}
}
// Data segement
#asm
psect data
global _vdpregs
_vdpregs:
defb 0x02 // Reg# 0 000000[M3][EV]
defb 0x60 // Reg# 1 [4/16k][BLANK][IE][M1][M2]0[SIZE][MAG]
defb 0x06 // Reg# 2 0000[NAME TABLE BASE ADDRESS] = 3C00h
defb 0xff // Reg# 3 [COLOR BASE ADDRESS] 3000h
defb 0x03 // Reg# 4 00000[PATTERN GENERATOR BASE ADDRESS] 1800h
defb 0x36 // Reg# 5 0[SPRITE ATTRIBUTE TABLE BASE ADDRESS] 3C80h
defb 0x07 // Reg# 6 00000[SPRITE PTRN GNRTR BASE ADDRESS] 3800h
defb 0x01 // Reg# 7 [TEXT COLOR 4bts][BACKDROP COLOR 4bts]
global _back1
_back1:
defb 00011100B
defb 00110110B
defb 11000011B
defb 11010011B
defb 11001011B
defb 11000011B
defb 01100110B
defb 00111100B
global _back1_color
_back1_color:
defb 00001111B
defb 00001111B
defb 00001111B
defb 00001111B
defb 00001111B
defb 00001111B
defb 00001111B
defb 00001111B
pad:
defs 0xbfff-0x8352// substitute each time with the address of "pad" from the .sym file
defb 01
#endasm
| | Huey msx professional Mensajes: 671 | Publicado: Abril 12 2006, 10:32   | LOL You're coding faster than I can ask for
I hope I have some time today at work (there's a big crisis at the moment) to test it. | | Huey msx professional Mensajes: 671 | Publicado: Abril 12 2006, 13:10   | I'ts working. Nice.
Don't think I will use the scrolling but it's nice to play with. I'going to build a map editor now......  | | ARTRAG msx master Mensajes: 1802 | Publicado: Abril 12 2006, 13:18   | Why not a scrolling? Please ! Consider the this possibility !
I'd love to see a new scroller game!    
I can support you in the scrolling implementation.
The most difficult thing is the sprite management, where the objects
can move and live in a map larger that the displayed window,
but it is C, it should be easy to cope with those problems. | | ARTRAG msx master Mensajes: 1802 | Publicado: Abril 12 2006, 14:48   | BTW, I have found a strange problem, you should Change
...
out (i8255portc),a
in a,(i8255portb)
ld l,
#endasm
}
in
...
out (i8255portc),a
in a,(i8255portb)
ld l,a
#endasm
}
It is strange you've got it working as it was | | Huey msx professional Mensajes: 671 | Publicado: Abril 12 2006, 15:51   | Scrolling in Screen2 only works good on Shooters and racing games. a 8x8 scrolling game makes moving a sprite by 2 pixels impossible.
If I go for a scrolling game it should only work in screen4 or higher. Making enemies that still move when they are not visual shouldn't be a problem (scrolling or no scrolling) main pr0blem would be having all level data in memory(only 16kb).
I saw the missing 'a' so I changed it (it was giving a warning when compiling)
| | ARTRAG msx master Mensajes: 1802 | Publicado: Abril 12 2006, 17:24   | Scrolling 8x8 is fine also in platforms and in AD&D style games.
BTW actually I have no idea about the game you want to develop, can you unveil some details?
About the 8x8 scrolling, I have to stress that there are many simple tricks to make excellent smooth scrollings: teh easiest is simply scroll at max speed half a page at time!
You see, the 8x8 scroll is smooth if it moves the page 8 pixels per frame. The problem is that the main character cannot run at that speed.
The solution is: move the main character at the speed you want and do not scroll until it reaches a given point of the screen (on the left or on the right), then scroll the screen of half a page at the max speed.
E.g. if the bar is the whole screen, scroll of half a screen at max speed when the main character reaches one of the two ‘S’.
|---S------S---|
<-- -->
This gives also a sort of "surprise effect" as unveil half a screen all in once | | ARTRAG msx master Mensajes: 1802 | Publicado: Abril 12 2006, 18:16   | This means that you have a screen large 32 characters ,
you can scroll it horizontally of 16 characters at time
each time the main sprite reaches character 8 on the left
or character 24 on the right.
Doing in this way, assuming ther you scrolled to the rigth,
after the scroll, your main sprite that was at character 24
should have gone at character 8.
| |
| |
| |