Author Topic: Jade  (Read 20911 times)

0 Members and 6 Guests are viewing this topic.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Jade
« Reply #30 on: March 13, 2013, 01:37:05 am »
What do you mean draw a string? Just print text? I also tested out AsmDream but i just can't get used to its syntax, i think for now i'm going to stick with the computer ;)

I just looked through the technical info and it's very well put together. Let's get some more sample games! :)

EDIT : Also, what instructions can currently be used with c/z flags? To make defining things easier, we could do something like:
lda = 0
adda = 1
adca = 2
;... etc.
c = 64
z = 128
;...
#define    lda(addr1  , addr2)     .db lda,addr1,addr2
#define    ldac(addr1  , addr2)     .db lda+c,addr1,addr2
#define    ldaz(addr1  , addr2)     .db lda+z,addr1,addr2

#define    adda(addr1 , addr2)     .db adda,addr1,addr2
#define    addac(addr1 , addr2)     .db adda+c,addr1,addr2
#define    addaz(addr1 , addr2)     .db adda+z,addr1,addr2

#define    adca(addr1 , addr2)     .db adca,addr1,addr2
#define    adcac(addr1 , addr2)     .db adca+c,addr1,addr2
#define    adcaz(addr1 , addr2)     .db adca+z,addr1,addr2
;etc.

EDIT2 : So i've been trying to figure out how to get a simple tilemap working but i can't think of how to do it without registers :/ Here's what i've got so far, a fake tilemap setup:

Spoiler For updated jade.inc:
Code: [Select]
;ports
sLSB0 = 00h
sMSB0 = 01h
sX0 = 02h
sY0 = 03h
sMethod0 = 04h
sLSB1 = 05h
sMSB1 = 06h
sX1 = 07h
sY1 = 08h
sMethod1 = 09h
sLSB2 = 0Ah
sMSB2 = 0Bh
sX2 = 0Ch
sY2 = 0Dh
sMethod2 = 0Eh
sLSB3 = 0Fh
sMSB3 = 10h
sX3 = 11h
sY3 = 12h
sMethod3 = 13h
sLSB4 = 14h
sMSB4 = 15h
sX4 = 16h
sY4 = 17h
sMethod4 = 18h
sLSB5 = 19h
sMSB5 = 1Ah
sX5 = 1Bh
sY5 = 1Ch
sMethod5 = 1Dh
sLSB6 = 1Eh
sMSB6 = 1Fh
sX6 = 20h
sY6 = 21h
sMethod6 = 22h
sLSB7 = 23h
sMSB7 = 24h
sX7 = 25h
sY7 = 26h
sMethod7 = 27h
key0 = 28h
key1 = 29h
key2 = 2Ah
key3 = 2Bh
key4 = 2Ch
key5 = 2Dh
key6 = 2Eh
keyMask = 2Fh
sMask = 30h
status = 31h ;bit 7 set means turn the system off, bit 0 = LCD update

;RAM =ates
saveSScreen = $86EC
stackptr = 32h
PClow = 33h+saveSScreen
PChigh = 34h+saveSScreen
stackbase = 80h+saveSScreen


_FlashToRam2 = 8054h
;flags
c = 64
z = 128
#define lda(addr1 , addr2) .db 0,addr1,addr2
#define adda(addr1 , addr2) .db 1,addr1,addr2
#define adca(addr1 , addr2) .db 2,addr1,addr2
#define suba(addr1 , addr2) .db 3,addr1,addr2
#define sbca(addr1 , addr2) .db 4,addr1,addr2
#define xora(addr1 , addr2) .db 5,addr1,addr2
#define ora(addr1 , addr2) .db 6,addr1,addr2
#define anda(addr1 , addr2) .db 7,addr1,addr2
#define cpa(addr1 , addr2) .db 8,addr1,addr2
#define inca(addr) .db 9,addr
#define rotl(addr) .db 10,addr
#define shftl(addr) .db 11,addr
#define pusha(addr) .db 12,addr
#define pop(addr) .db 13,addr
#define inv(addr) .db 14,addr
#define ldira(addr,size) .db 15,addr,size

#define ldc(addr , const) .db 16,addr,const
#define addc(addr , const) .db 17,addr,const
#define adcc(addr , const) .db 18,addr,const
#define subc(addr , const) .db 19,addr,const
#define sbcc(addr , const) .db 20,addr,const
#define xorc(addr , const) .db 21,addr,const
#define orc(addr , const) .db 22,addr,const
#define andc(addr , const) .db 23,addr,const
#define cpc(addr , const) .db 24,addr,const
#define deca(addr) .db 25,addr
#define rotr(addr) .db 26,addr
#define shftr(addr) .db 27,addr
#define pushc(const) .db 28,const
#define ex(addr1,addr2) .db 29,addr1,addr2
#define bits(addr,const) .db 30,addr,const
#define ldirc(addr,size) .db 31,addr,size

#define ret() .db 32
#define setz() .db 33
#define setc() .db 34
#define togz() .db 35
#define togc() .db 36
#define jp1(Addr) .db 37,Addr
#define jp2(Addr) .db 38,Addr
#define jrf(offset) .db 39,offset-1-$
#define jrfz(offset) .db 39+z,offset-1-$
#define jrb(offset) .db 40,1-offset+$
#define call1(Addr) .db 41,Addr
#define call2(Addr) .db 42,Addr
#define callf(offset) .db 43,offset-1-$
#define callb(offset) .db 44,1-offset+$

#define ldcz(addr1 , const) .db 16+128,addr1,const
#define jrbz(offset) .db 40+128,1-offset+$
#define incaz(addr) .db 9+128,addr
#define decaz(addr) .db 25+128,addr
#define retz() .db 32+128

;key0
jkDown = %11111110
jkRight = %11111101
jkLeft = %11111011
jkUp = %11110111
;key1
jkClear = %10111111
;key6
jkGraph = 254
jkTrace = 253
jkZoom = 251
jkWindow = 247
jkY = 239
jk2nd = 223
jkMode = 191
jkDel = 127

lcdupdatebit = 0
spriteupdatebit = 1
Spoiler For jadeGame.asm:
Code: [Select]
"Jade.inc"
.org $00

mapX = 252
mapY = 253
counter1 = 254
counter2 = 255

#define BIT ^$FF

start:
ldirc(keyMask,2) ;keyMask, spriteMask
.db %0100011,%1 ;enable key groups 0 and 1, sprite0
ldirc(sLSB0,5)
.dw $100+sprite \ .db 0,0,2
ldirc(mapX,4)
.db 0,0,12,2
tilemap:
orc(status,2) ;tell the status port to draw the sprites
addc(sX0,8)
deca(counter1)
togz()
jrbz(tilemap)
ldc(counter1,12)
ldc(sX0,0)
ldc(sY0,8*7)
deca(counter2)
togz()
jrbz(tilemap)
ldc(sY0,8*6)
loop:
orc(status,2) ;tell the status port to draw the sprites
orc(status,3) ;tell the status port to update the LCD, then draw the sprites
bits(key0,jkDown BIT)
incaz(sY0)
bits(key0,jkUp BIT)
decaz(sY0)
bits(key0,jkLeft BIT)
incaz(sX0)
bits(key0,jkRight BIT)
decaz(sX0)
cpc(key1,jkClear)
ldcz(status,$80)
jrb(loop)

map:
.db 1,1,1,1,1,1,1,1,1,1,1,1
.db 1,0,0,0,0,0,0,0,0,0,0,1
.db 1,0,0,0,0,0,0,0,0,0,0,1
.db 1,0,0,0,0,0,0,0,0,0,0,1
.db 1,0,0,0,0,0,0,0,0,0,0,1
.db 1,0,0,0,0,0,0,0,0,0,0,1
.db 1,0,0,0,0,0,0,0,0,0,0,1
.db 1,1,1,1,1,1,1,1,1,1,1,1

sprite:
.db %11111111
.db %11011011
.db %10000001
.db %10011001
.db %10011001
.db %10000001
.db %11011011
.db %11111111
« Last Edit: March 13, 2013, 02:58:01 am by chickendude »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Jade
« Reply #31 on: March 13, 2013, 08:59:44 am »
What do you mean draw a string? Just print text? I also tested out AsmDream but i just can't get used to its syntax, i think for now i'm going to stick with the computer ;)
Yes, that is what I mean about the text. And yeah, the syntax does take some time to get used to XD. I wonder if there is a way to get Mimas to work nicely for it.
EDIT : Also, what instructions can currently be used with c/z flags? To make defining things easier, we could do something like:
lda = 0
adda = 1
adca = 2
;... etc.
c = 64
z = 128
;...
#define    lda(addr1  , addr2)     .db lda,addr1,addr2
#define    ldac(addr1  , addr2)     .db lda+c,addr1,addr2
#define    ldaz(addr1  , addr2)     .db lda+z,addr1,addr2

#define    adda(addr1 , addr2)     .db adda,addr1,addr2
#define    addac(addr1 , addr2)     .db adda+c,addr1,addr2
#define    addaz(addr1 , addr2)     .db adda+z,addr1,addr2

#define    adca(addr1 , addr2)     .db adca,addr1,addr2
#define    adcac(addr1 , addr2)     .db adca+c,addr1,addr2
#define    adcaz(addr1 , addr2)     .db adca+z,addr1,addr2
;etc.
Every instruction should be able to be used with the c and z flag, I just didn't finish including all of them in the .inc file yet.
EDIT2 : So i've been trying to figure out how to get a simple tilemap working but i can't think of how to do it without registers :/ Here's what i've got so far, a fake tilemap setup:

That looks really nice! What do you mean that you cannot get it to work without registers? Do you mean you cannot get it to work without using RAM? That is the only way that I can think of doing it. I plan to look at your code and try my own hand at it, too, because that does look nice.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Jade
« Reply #32 on: March 13, 2013, 09:59:33 am »
Well the image isn't an actual tilemap, it's just me copying the sprite over a few times. What i wanted to do is read map+0, check what value it is and draw the appropriate sprite. Then read map+1, map+2, etc. Essentially read a tilemap from memory, but i couldn't figure out how to do it. You can check a specific byte in memory, but can you check what (map) is, then what (map+1) is, etc. ? Maybe my mind just froze up and i'm missing something super simple.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Jade
« Reply #33 on: March 13, 2013, 10:04:53 am »
Hmm, I thought of a clever trick:

-copy the map to the end of the stack (so make sure the last byte is at address 255)
-Save the stack pointer
-Set the stack pointer to 0
-use pop() to read the bytes quickly, drawing the appropriate sprite. You can do 8 sprites at a time, so maybe draw whole columns at a time?
-Set the stack pointer back to what it was


Also, I am going to start getting in the habit of storing other info like coordinates to stackbase-1, stackbase-2, and whatnot.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Jade
« Reply #34 on: March 13, 2013, 10:24:11 am »
Hmm, interesting idea, i'll try that out. The stack goes up, doesn't it? (pushing increases the sp, popping decreases)

I've got a couple ideas, but i want to test them out first to see if they'll actually work out.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Jade
« Reply #35 on: March 13, 2013, 10:34:07 am »
Yes, that is how it works, and it should wrap around. Also, I just tested it and it worked :D It isn't all that fast, but it works! Here is the code:
Code: [Select]
spriteX = stackbase-1
spriteY = stackbase-2
tilenum = stackbase-3
.org 0
     ldc(keyMask,255)
     ldirc(160,96)
;tilemap data
;drawn by column
     .db 1,1,1,1,1,1,1,1
     .db 1,0,2,2,2,2,0,1
     .db 1,0,0,2,2,0,0,1
     .db 1,0,0,0,0,0,0,1
     .db 1,0,0,0,0,0,0,1
     .db 1,0,0,0,0,0,0,1
     .db 1,0,0,0,0,0,0,1
     .db 1,0,0,0,0,0,0,1
     .db 1,0,0,0,0,0,0,1
     .db 1,0,0,2,2,0,0,1
     .db 1,0,2,2,2,2,0,1
     .db 1,1,1,1,1,1,1,1
     ldirc(sMSB0,4)
       .db 1,96,0,2
     ldc(sMask,1)
TileMap:
     ldc(sY0,64)
     subc(sX0,8)
     jrfc(Start)
TileMapLoop:
     subc(sY0,8)
     jrbc(TileMap)
     pop(tilenum)
     rotl(tilenum)
     rotl(tilenum)
     rotl(tilenum)
     addc(tilenum,tiles)
     lda(sLSB0,tilenum)
     orc(status,2)
     jrb(TileMapLoop)
tiles:
     .db 0,0,0,0,0,0,0,0
     .db 3Ch,42h,81h,81h,81h,81h,42h,3Ch
     .db 3Ch,7Eh,$FF,$FF,$FF,$FF,7Eh,3Ch     
Start:
     ldc(stackptr,0)
     orc(status,1)
     ldc(status,80h)

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Jade
« Reply #36 on: March 13, 2013, 10:54:47 am »
Very cool! Now how would you handle collision detection?

EDIT: And one of my ideas was just to use the LSB as the tile id in your tilemaps instead of multiplying it by 8 and calculating the offset. Then you could just do something like pop(sLSB0).
« Last Edit: March 13, 2013, 10:57:06 am by chickendude »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Jade
« Reply #37 on: March 13, 2013, 11:02:34 am »
We need indirection, don't we? Gah, I cannot believe I forgot to add that in. Do you have any suggestions on how it could be implemented. I was thinking maybe add a few more instructions like ldi(), addi(), adci(), ... ? Those would use the second argument for indirection, so something like ldi(tempbyte,offsetptr) would read the byte at offsetptr to figure out where to load a byte from and store it at tempbyte.

EDIT: In reply to your edit, that is a brilliant idea o.o that should remove 9 bytes of code, I believe and make it run faster.

It actually removed 12 bytes, nice!

EDIT2: I have added in indirection for some of the instructions, but the way it is implemented, you cannot execute instructions conditionally. I could change this by making a byte indicate that the next instruction is indirection. Then it would be possible to execute them conditionally.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Jade
« Reply #38 on: March 13, 2013, 07:31:29 pm »
Yeah, that's what i was thinking about the indirection, being able to store an address in a variable and read data from the address stored in that variable, and not the address number. It seems like a kinda roundabout way of doing things but i think it'd be really useful. I'm curious how the cpi statement would be, though. I think it'd be convenient to have cpi(ind_addr,addr) and cpi(ind_addr,const) but that's backwards from the normal instruction set (cpi(addr,ind_addr)). Anyway, with indirection you can do lots more cool things :)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Jade
« Reply #39 on: March 13, 2013, 07:34:10 pm »
If I go with having a prefix byte, I will have ind1() and ind2() so that it can be specified which byte has indirection performed on it. It wouldn't make any sense to use indirection ont eh second argument of something like ldc() since that would be equivalent (but slower and larger) to lda().

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: Jade
« Reply #40 on: March 14, 2013, 09:39:02 am »
Hey Zedy...

Good to see you on my old mail box =]

About asmdream current status :
I'm actually thinking to redesign the whole thing.
I would like to code a text editor, compatible with text files (ANSI at least) written on a computer, and add it into the app.
Also, i'm probably gonna change the whole syntax so that asmdream can read sources and includes written for pc assemblers (no prgm editor anymore).
Maybe the assembler and the editor will both be included in a bigger project i'm thinking of (a shell actually).
So asmdream as you know it will be very different, but also a lot better.

About your request :
What asmdream does was not initially designed to be "called" from another code.
I mean, it would probably require some changes in the original source.
I'm not saying it's impossible, but it requires a bit of work on my side.
I'm gonna take a closer look at the source and see if that can be done without too much trouble...

Keep up the good work mate =]

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Jade
« Reply #41 on: March 14, 2013, 11:03:42 am »
Wow, awesome, and thanks! What I was thinking was that maybe there could be a place where an external program could pass the location of the source data in HL and the size of the source data in BC, or something like that. I was also thinking of making a small font editor for editing BASIC programs so that the source would look neater, so that could help. This would also make it easier to use lowercase letters.

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: Jade
« Reply #42 on: March 17, 2013, 09:13:53 am »
Re, xed.

I took a look at the source and i think something can be done here.
I just need more precisions :
Do you want asmdream to do its work silently (without displaying anything) ?
If yes, you'll have to handle the display of error messages by yourself (I can provide error data).
If no, what do you want it to display ?
Also, do you want the goto feature to be executed by asmdream or do you intend to code one yourself ?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Jade
« Reply #43 on: March 17, 2013, 09:19:59 am »
If you want to have the ASMDream compiling screen display, that would be fine! If not, that is fine with me, too, and I could handle error messages and the goto feature if needed.

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: Jade
« Reply #44 on: March 17, 2013, 09:42:47 am »
Well, the less changes i have to make, the better it is for me actually =P
2 alternatives i'm thinking of :
1) asmdream will run as usual, except that when entering the source name input screen, the field will already be filled with the name you've passed to it.
2) asmdream will directly jump to the simulation/writing screen, skipping the splash and source name input screens.
Tell me the one you prefer or if you need to be able to do something else.