ld bc,-7 ;c=-7, b=0
Nope ... ld bc,-7
gives c=-7,b=255 (FFF9h)
Ah dang it haha yer right
To be frank, a better -readable- solution would be
LD BC,7
SUB A,C
#cleancode
Ah dang it haha yer right
To be frank, a better -readable- solution would be
LD BC,7
SUB A,C
#cleancode
LoL
Ld bc,f9h
Add a,c
#obscurecode
Ah dang it haha yer right
To be frank, a better -readable- solution would be
LD BC,7
SUB A,C
#cleancode
LoL
Ld bc,f9h
Add a,c
#obscurecode
ld bc, +((-7 << 8) and $ff00) +(0 and $00ff) add c
#middlegroundcode
Well, we can go further. cuz what is this magic number 7?
A label to that would be great!
ScrollOffset: EQU 7 LD C,ScrollOffset SUB A,C
Now #cleancode is done.
/backontopic
Here, I made a video of my demo inspired by Atari 2600's Entombed using the same maze generation algorithm.
I see no flickering. So you fixed it?
LD BC,0000H ; REG 0: MODE 1
CALL WRITE_REGISTER
LD BC,01C2H ; REG 1: MODE 1, 16K, NO INTERRUPTS, C0=8X8 C2=16X16 C1=ENLARGED C3=NORMAL
CALL WRITE_REGISTER
LD BC,0201H ; REG 2: NAME TABLE 0400H
CALL WRITE_REGISTER
LD BC,0380H ; REG 3: COLOR TABLE $2000
CALL WRITE_REGISTER
LD BC,0400H ; REG 4: PATTERN TABLE 0000H
CALL WRITE_REGISTER
LD BC,053CH ; REG 5: SPRITE ATTRIBUTE TABLE 1B00H
CALL WRITE_REGISTER
LD BC,0607H ; REG 6: SRITE PATTERN TABLE 3800H
CALL WRITE_REGISTER
LD BC,0700H ; REG 7: BACKGROUND COLOR (BLACK)
CALL WRITE_REGISTER
VRAM_PATTERNS: EQU $0000
VRAM_NAME_TABLE: EQU $0400 ; RELOCATED FOR SCROLLING VRAM_SPRITE_ATTR: EQU $1800
VRAM_SPRITE_ATTR: EQU $1E00
VRAM_COLOR_TABLE: EQU $2000
VRAM_SPRITE_PATTENS: EQU $3800
I know this is vague but after I set this up and my patterns all I had to do is change register 4
1, 2, 3, 4 or 4, 3, 2, 1
Graphics mode 0 I believe on the MSX?
INITIALIZE_GAME: ; LOAD TILES TO VRAM. USEING MODE 1. SET PATTERNS AT VDP ADDRESS THEN ACCESED WITH REGISTER 4.
LD BC,01C2H ; DISABLE NMI
CALL WRITE_REGISTER
LD HL, VRAM_PATTERNS+$0000 ; SCROLL SET 0
LD DE, SCROLL_SET
LD BC, TILE_COUNT*8
CALL LDIRVM
LD HL, VRAM_PATTERNS+$0000+TILE_COUNT*8 ; NUMBER + LETTERS SET 0
LD DE, NUMBERS
LD BC, 14*8
CALL LDIRVM
LD HL, VRAM_PATTERNS+$0800 ; SCROLL SET 1
LD DE, SCROLL_SET
LD BC, TILE_COUNT*8
CALL LDIRVM
LD HL, VRAM_PATTERNS+$0800+$08
LD DE, SCROLL_SET+03*8
LD BC, 2*8
CALL LDIRVM
LD HL, VRAM_PATTERNS+$0800+TILE_COUNT*8 ; NUMBER + LETTERS SET 1
LD DE, NUMBERS
LD BC, 14*8
CALL LDIRVM
LD HL, VRAM_PATTERNS+$1000 ; SCROLL SET 3
LD DE, SCROLL_SET
LD BC, TILE_COUNT*8
CALL LDIRVM
LD HL, VRAM_PATTERNS+$1000+$08
LD DE, SCROLL_SET+05*8
LD BC, 2*8
CALL LDIRVM
LD HL, VRAM_PATTERNS+$1000+TILE_COUNT*8 ; NUMBER + LETTERS SET 3
LD DE, NUMBERS
LD BC, 14*8
CALL LDIRVM
LD HL, VRAM_PATTERNS+$1800 ; SCROLL SET 4
LD DE, SCROLL_SET
LD BC, TILE_COUNT*8
CALL LDIRVM
LD HL, VRAM_PATTERNS+$1800+$08
LD DE, SCROLL_SET+07*8
LD BC, 2*8
CALL LDIRVM
LD HL, VRAM_PATTERNS+$1800+TILE_COUNT*8 ; NUMBER + LETTERS SET 4
LD DE, NUMBERS
LD BC, 14*8
CALL LDIRVM
LD HL, VRAM_SPRITE_PATTENS ; UPLOAD SPRITE PATTERNS TO THE VDP
LD DE, EYES_FORWARD_SP
LD BC, 32*SPRITE_COUNT
CALL LDIRVM
LD DE, TEMP_HUD
LD HL, VRAM_NAME_TABLE+640
LD BC, 128
CALL LDIRVM
LD BC,01E2H ; ENABLE NMI
CALL WRITE_REGISTER
This loaded in the patterns at the proper addresses and use register 4 as indicated.
I see no flickering. So you fixed it?
Yes, it's fixed. I change the tile layout in memory so I could copy them in a single operation (like you suggested) to this:
The green tiles at the beginning is where I copy the other tiles from RAM into VRAM. In groups of three per frame.
I also added halt
just before update_tile()
to smooth things out a bit (thanks, geijoenr). Most of the game loop is still in C so I am happy with the results.
#include #include extern const uint8_t map_data[MAP_WIDTH*MAP_HEIGHT]; uint8_t *map_data_p = map_data; void run_loop() { int8_t frame = -1; bool game_running = true; while (game_running) { frame++; __asm halt __endasm; // wait for vsync update_tiles(); // move the maze up pixel by pixel by changing the pattern table if (frame == 7) { frame = -1; // reset frame counter map_data_p += 32; // update map pointer by width size (point to the next line) update_map(); // move the maze up tile by tile by changing the name table } // process user input and update sprites // ... wait(); // wait the allotted frame time to finish }
Finally, here is what my code does: Following this paper at https://arxiv.org/abs/1811.02035 (Entombed: An archaeological examination of an Atari 2600 game) I implemented a version of the maze generator from Atari 2600's Entombed on the MSX1. And added smooth scroll to make it more interesting.
Here is a new video with bgm from the Goonies added just for the mood.