View unanswered posts | View active topics It is currently Mon Apr 21, 2014 12:47 am



Reply to topic  [ 5 posts ] 
 how do you do calculus physics in Assembly like in Donkey Ko 
Author Message
User avatar

Joined: Wed Jun 09, 2010 3:30 am
Posts: 9
Location: Melbourne, Australia
Post how do you do calculus physics in Assembly like in Donkey Ko
how do you do calculus physics in Assembly like in Donkey Kong does?

_________________
http://www.rolandszi.com


Thu Oct 07, 2010 7:27 am
Profile WWW
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 279
Post 
The same way you do with C, C++, Java, etc. first you understand the physical model (trajectory in this case), and the create a computer model of it. All my books show this simple example, as do other game development books. So just read one of them on game physics and see for yourself. Then if you want to convert it to ASM then that's a language problem, not a programming problem and you have to be good at ASM.

Andre'


Thu Oct 07, 2010 5:12 pm
Profile WWW
User avatar

Joined: Tue Dec 06, 2005 8:01 am
Posts: 23
Location: U.S.A.
Post 
Here's a super simple example of ASM Physics, a bouncing ball. Very simple, but enough to get you somewhat started I think. If you can already do that in ASM then just ignore me. ^^

Code:
;Pixel Animation
;8/02/07
;Ball Bouncing
;By Joe Nesbella

start:
lda #$00 ;X Position
sta $00

lda #$00 ;Y Position
sta $01

lda #02 ;Colour
sta $03

lda #$0f ;ballx
sta $1A ;ballX storage

lda #$00 ;ballY
sta $1B ;ballY Storage

lda #$00 ;ball dir x currently right
sta $1C

lda #$00 ;ball dir y currently down
sta $1D

mainLoop:
lda #$80
sta $1E
jsr delay
jmp checkHDir


checkHDir:
lda $1C ;Load X Dir
cmp #$00 ;Going Right?
beq checkRight
jmp checkLeft ;If not right go left

checkVDir:
lda $1D ;Load Y DIr
cmp #$00 ;Going Down?
beq checkDown
jmp checkUp

delay:
dec $1E
lda $1E
cmp #$00
bne delay
rts

checkRight:
lda $1A ;Load X Coord
cmp #$1f
bne goRight
lda #$01 ;Change Dir to Left
sta $1C
jmp checkHDir

checkLeft:
lda $1A ;Load X Coord
cmp #$00
bne goLeft
lda #$00 ;Change Dir to Right
sta $1C
jmp checkHDir

checkDown:
lda $1B ;Load Y Coord
cmp #$1f ;Check against bottom of screen
bne goDown
lda #$01 ;Change to Up
sta $1D
jmp checkVDir

checkUp:
lda $1B ;Load Y Coord
cmp #$00 ;Check Against Top Of Screen
bne goUp
lda #$00 ;Change to Down
sta $1D
jmp checkVDir

goRight:
;Erase Pixel First
lda $1A ;Load X Coord
sta $00

lda $1B ;Load Y Coord
sta $01
jsr erasePixel
inc $1A ;Increase X Coord 1
lda $1A ;Load X Coord
sta $00
jmp checkVDir

goLeft:
;Erase Pixel First
lda $1A ;Load X Coord
sta $00

lda $1B ;Load Y Coord
sta $01
jsr erasePixel
dec $1A ;Decrease X Coord 1
lda $1A ;Load X Coord
sta $00
jmp checkVDir

goDown:
inc $1B ;Increase Y Coord
lda $1B ;Load Y Coord
sta $01
jmp drawPixel


goUp:
dec $1B ;Increase Y Coord
lda $1B ;Load Y Coord
sta $01
jmp drawPixel

drawPixel:
ldx $01 ;Load Y Position

lda highByte, x
sta $0B ;Store High Byte

lda lowByte, x
sta $0A ;Store Low Byte

lda $00 ;Load X Coordinate probably should be
adc $0A ;ANDed with 31 to keep on same line
sta $0A ;This gives us our complete address

lda $03 ;Load the Colour
ldx #$00 ;Make sure X offset is 0
sta ($0A, x) ;Get our location
jmp mainLoop

erasePixel:
ldx $01 ;Load Y Position

lda highByte, x
sta $0B ;Store High Byte

lda lowByte, x
sta $0A ;Store Low Byte

lda $00 ;Load X Coordinate probably should be
adc $0A ;ANDed with 31 to keep on same line
sta $0A ;This gives us our complete address

lda #$00 ;Load the Colour
ldx #$00 ;Make sure X offset is 0
sta ($0A, x) ;Get our location
rts

;High Byte Y Coordinate Address Lookup
highByte:
dcb $02, $02, $02, $02, $02, $02, $02, $02
dcb $03, $03, $03, $03, $03, $03, $03, $03
dcb $04, $04, $04, $04, $04, $04, $04, $04
dcb $05, $05, $05, $05, $05, $05, $05, $05

;Low Byte Y Coordinate Address Lookup
lowByte:
dcb $00, $20, $40, $60, $80, $A0, $C0, $E0
dcb $00, $20, $40, $60, $80, $A0, $C0, $E0
dcb $00, $20, $40, $60, $80, $A0, $C0, $E0
dcb $00, $20, $40, $60, $80, $A0, $C0, $E0


It's all 6502 ASM (my favorite) code and is designed for the website 6502ASM.com

_________________
The wolf and his mate howl, taking solace in the silver moon. Pressing ever foreward to see what the future holds.

Mao Mao Games


Wed Oct 20, 2010 12:28 am
Profile WWW
User avatar

Joined: Sat Nov 21, 2009 6:16 pm
Posts: 10
Post 
Jinroh wrote:
Here's a super simple example of ASM Physics, a bouncing ball. Very simple, but enough to get you somewhat started I think. If you can already do that in ASM then just ignore me. ^^

Code:
;Pixel Animation
;8/02/07
;Ball Bouncing
;By Joe Nesbella

start:
lda #$00 ;X Position
sta $00

lda #$00 ;Y Position
sta $01

lda #02 ;Colour
sta $03

lda #$0f ;ballx
sta $1A ;ballX storage

lda #$00 ;ballY
sta $1B ;ballY Storage

lda #$00 ;ball dir x currently right
sta $1C

lda #$00 ;ball dir y currently down
sta $1D

mainLoop:
lda #$80
sta $1E
jsr delay
jmp checkHDir


checkHDir:
lda $1C ;Load X Dir
cmp #$00 ;Going Right?
beq checkRight
jmp checkLeft ;If not right go left

checkVDir:
lda $1D ;Load Y DIr
cmp #$00 ;Going Down?
beq checkDown
jmp checkUp

delay:
dec $1E
lda $1E
cmp #$00
bne delay
rts

checkRight:
lda $1A ;Load X Coord
cmp #$1f
bne goRight
lda #$01 ;Change Dir to Left
sta $1C
jmp checkHDir

checkLeft:
lda $1A ;Load X Coord
cmp #$00
bne goLeft
lda #$00 ;Change Dir to Right
sta $1C
jmp checkHDir

checkDown:
lda $1B ;Load Y Coord
cmp #$1f ;Check against bottom of screen
bne goDown
lda #$01 ;Change to Up
sta $1D
jmp checkVDir

checkUp:
lda $1B ;Load Y Coord
cmp #$00 ;Check Against Top Of Screen
bne goUp
lda #$00 ;Change to Down
sta $1D
jmp checkVDir

goRight:
;Erase Pixel First
lda $1A ;Load X Coord
sta $00

lda $1B ;Load Y Coord
sta $01
jsr erasePixel
inc $1A ;Increase X Coord 1
lda $1A ;Load X Coord
sta $00
jmp checkVDir

goLeft:
;Erase Pixel First
lda $1A ;Load X Coord
sta $00

lda $1B ;Load Y Coord
sta $01
jsr erasePixel
dec $1A ;Decrease X Coord 1
lda $1A ;Load X Coord
sta $00
jmp checkVDir

goDown:
inc $1B ;Increase Y Coord
lda $1B ;Load Y Coord
sta $01
jmp drawPixel


goUp:
dec $1B ;Increase Y Coord
lda $1B ;Load Y Coord
sta $01
jmp drawPixel

drawPixel:
ldx $01 ;Load Y Position

lda highByte, x
sta $0B ;Store High Byte

lda lowByte, x
sta $0A ;Store Low Byte

lda $00 ;Load X Coordinate probably should be
adc $0A ;ANDed with 31 to keep on same line
sta $0A ;This gives us our complete address

lda $03 ;Load the Colour
ldx #$00 ;Make sure X offset is 0
sta ($0A, x) ;Get our location
jmp mainLoop

erasePixel:
ldx $01 ;Load Y Position

lda highByte, x
sta $0B ;Store High Byte

lda lowByte, x
sta $0A ;Store Low Byte

lda $00 ;Load X Coordinate probably should be
adc $0A ;ANDed with 31 to keep on same line
sta $0A ;This gives us our complete address

lda #$00 ;Load the Colour
ldx #$00 ;Make sure X offset is 0
sta ($0A, x) ;Get our location
rts

;High Byte Y Coordinate Address Lookup
highByte:
dcb $02, $02, $02, $02, $02, $02, $02, $02
dcb $03, $03, $03, $03, $03, $03, $03, $03
dcb $04, $04, $04, $04, $04, $04, $04, $04
dcb $05, $05, $05, $05, $05, $05, $05, $05

;Low Byte Y Coordinate Address Lookup
lowByte:
dcb $00, $20, $40, $60, $80, $A0, $C0, $E0
dcb $00, $20, $40, $60, $80, $A0, $C0, $E0
dcb $00, $20, $40, $60, $80, $A0, $C0, $E0
dcb $00, $20, $40, $60, $80, $A0, $C0, $E0


It's all 6502 ASM (my favorite) code and is designed for the website 6502ASM.com


Jinroh,

Check out: http://www.google.com/url?sa=t&source=w ... kWAZPddsXA

Almost the same instructions I bet you would not need much training to program the 9s12 too.

:-D


Wed Oct 20, 2010 1:36 pm
Profile
User avatar

Joined: Wed Jun 09, 2010 3:30 am
Posts: 9
Location: Melbourne, Australia
Post 
most engines use newtonian physics modelling I suppose.

_________________
http://www.rolandszi.com


Tue Nov 09, 2010 6:29 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.