[TI ASM] Displaying random text
Moderator: MaxCoderz Staff
-
- New Member
- Posts: 65
- Joined: Sun 03 Apr, 2005 7:55 pm
- Location: The seventh circle of Hell.
- Contact:
[TI ASM] Displaying random text
I need to know the equivelant of
RandInt(1,5)->A
If A=1
Disp "blah"
If A=2
...
in ASM...can anyone help me? I'm planning on porting my KillBot game from BASIC to Asm
RandInt(1,5)->A
If A=1
Disp "blah"
If A=2
...
in ASM...can anyone help me? I'm planning on porting my KillBot game from BASIC to Asm
Truly great madness cannot be achieved without significant intelligence.
http://www.xanga.com/jakku_kun, rants by me.
http://www.xanga.com/jakku_kun, rants by me.
Code: Select all
If A=1
Code: Select all
cp $01
![Neutral :|](./images/smilies/grayscale_blank.gif)
As to random #s, I'm too lazy to explain at the moment (there are many ways to get one, the question is how much "randomness" you want in it).
"If SOURCE is outlawed, only outlaws will have SOURCE."
-
- New Member
- Posts: 65
- Joined: Sun 03 Apr, 2005 7:55 pm
- Location: The seventh circle of Hell.
- Contact:
I only need to display about 16 bits of text for the bots "attacks".go to ticalc.org and download Killbot, and look at the source for KILLBOT1 to see what I mean.
Truly great madness cannot be achieved without significant intelligence.
http://www.xanga.com/jakku_kun, rants by me.
http://www.xanga.com/jakku_kun, rants by me.
- Shadow Phoenix
- Calc Guru
- Posts: 835
- Joined: Mon 03 Jan, 2005 7:54 pm
- Location: out there. seriosly.
If you are using Ion/Mirage :
Code: Select all
ld b,4 ;From 0--->4 b=upper boundy
ionRandom ; outputs a random number between zero (0) and a number ld b,1 ;you load into register b
add a,b ;But you want 1---> 5 so we add one to a
cp 1
jp z, DisplayWhatHappensIfRandomIs1
cp 2
jp z, DisplayWhatHappensIfRandomIs2
Life is getting better.
-
- Extreme Poster
- Posts: 479
- Joined: Fri 17 Dec, 2004 11:09 pm
- Contact:
Code: Select all
ld b,4 ;From 0--->4 b=upper boundy
ionRandom ; outputs a random number between zero (0) and a number
inc a ;But you want 1---> 5 so we add one to a
cp 1
jp z, DisplayWhatHappensIfRandomIs1
cp 2
jp z, DisplayWhatHappensIfRandomIs2
![Very Happy :D](./images/smilies/grayscale_happy.gif)
Code: Select all
ld b,4 ;From 0--->4 b=upper boundy
ionRandom ; outputs a random number between zero (0) and a number
or a
jp z, DisplayWhatHappensIfRandomIs1
cp 1
jp z, DisplayWhatHappensIfRandomIs2
This code works for any number of strings, just change the table and the random range from 8.
Code: Select all
ld b,8
call ionrandom
ld h,0
ld l,a
add hl,hl
ld bc,stringtable
add hl,bc
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
bcall(_puts)
...
StringTable:
.dw String1
.dw String2
.dw String3
.dw String4
.dw String5
.dw String6
.dw String7
.dw String8
String1: .db "This is string 1!",0
String2: .db "This is string 2!",0
String3: .db "This is string 3!",0
String4: .db "This is string 4!",0
String5: .db "This is string 5!",0
String6: .db "This is string 6!",0
String7: .db "This is string 7!",0
String8: .db "This is string 8!",0
You know your hexadecimal output routine is broken when it displays the character 'G'.
-
- New Member
- Posts: 65
- Joined: Sun 03 Apr, 2005 7:55 pm
- Location: The seventh circle of Hell.
- Contact:
Could you break that code down and explain the bits? Otherwise i wouldnt be learning anything, just copying what others did. Plus, i dunno how to use the ion routines or anything
![Puzzled :puzzled:](./images/smilies/grayscale_puzzled.gif)
Truly great madness cannot be achieved without significant intelligence.
http://www.xanga.com/jakku_kun, rants by me.
http://www.xanga.com/jakku_kun, rants by me.
Code: Select all
ld b,8
call ionrandom
Then the code uses A as an index into the string table.
Code: Select all
ld h,0
ld l,a
Code: Select all
add hl,hl
Code: Select all
ld bc,stringtable
add hl,bc
Code: Select all
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
Code: Select all
bcall(_puts)
...
The string table contains a bunch of .dw's. .dw defines a 16-bit (2 byte) word, such as an Address. The string table contains a bunch of addresses of each text string.
Code: Select all
StringTable:
.dw String1
.dw String2
.dw String3
.dw String4
.dw String5
.dw String6
.dw String7
.dw String8
Code: Select all
String1: .db "This is string 1!",0
String2: .db "This is string 2!",0
String3: .db "This is string 3!",0
String4: .db "This is string 4!",0
String5: .db "This is string 5!",0
String6: .db "This is string 6!",0
String7: .db "This is string 7!",0
String8: .db "This is string 8!",0
You know your hexadecimal output routine is broken when it displays the character 'G'.
-
- New Member
- Posts: 65
- Joined: Sun 03 Apr, 2005 7:55 pm
- Location: The seventh circle of Hell.
- Contact:
Ahh, thanks a lot. Now, to use ionRandom, you just include ion in the header?
Truly great madness cannot be achieved without significant intelligence.
http://www.xanga.com/jakku_kun, rants by me.
http://www.xanga.com/jakku_kun, rants by me.
-
- Calc Wizard
- Posts: 526
- Joined: Tue 08 Mar, 2005 1:37 am
- Location: who wants to know?
- Contact:
-
- New Member
- Posts: 65
- Joined: Sun 03 Apr, 2005 7:55 pm
- Location: The seventh circle of Hell.
- Contact:
What is the proper header for an Ion program?
Truly great madness cannot be achieved without significant intelligence.
http://www.xanga.com/jakku_kun, rants by me.
http://www.xanga.com/jakku_kun, rants by me.
- Shadow Phoenix
- Calc Guru
- Posts: 835
- Joined: Mon 03 Jan, 2005 7:54 pm
- Location: out there. seriosly.
Code: Select all
.nolist ;remember, first we need the ION Header
#include "ion.inc"
.list
#ifdef TI83P
.org progstart-2
.db $BB,6D
#else
.org progstart
#endif
ret
jr nc,begin ;where to go to start the program
.db "First ION prgm!",0 ;the title
Life is getting better.
-
- New Member
- Posts: 65
- Joined: Sun 03 Apr, 2005 7:55 pm
- Location: The seventh circle of Hell.
- Contact:
Ahhh, doumo arigato gozaimasu! Maybe i can get this damned game to work after all.
Truly great madness cannot be achieved without significant intelligence.
http://www.xanga.com/jakku_kun, rants by me.
http://www.xanga.com/jakku_kun, rants by me.
-
- New Member
- Posts: 65
- Joined: Sun 03 Apr, 2005 7:55 pm
- Location: The seventh circle of Hell.
- Contact:
Okay, maybe not. here's the source, maybe one of you folk can fix it?
.NOLIST
#define EQU .equ
#define equ .equ
#define END .end
#define end .end
#include "ti83plus.inc"
#include "mirage.inc"
.LIST
#ifdef TI83P
.org progstart-2
.db $BB,6D
#else
.org progstart
#endif
ret
jr nc,rnd
.db "ION prgm!",0
rnd: ;choose a random number and go
ld b,16 ;to corresponding string
call irandom
ld h,0
ld l,a
add hl,hl
ld bc,atktable
add hl, bc
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
B_CALL(_PutS)
ret
atktable: ;tells it what string to display
.dw atk1
.dw atk2
.dw atk3
.dw atk4
.dw atk5
.dw atk6
.dw atk7
.dw atk8
.dw atk9
.dw atk10
.dw atk11
.dw atk12
.dw atk13
.dw atk14
.dw atk15
.dw atk16
atk1: ;the strings to be displayed
.db "(stabs user)",0
jp rnd
atk2:
.db "(kicks user)",0
jp rnd
atk3:
.db "(throws user",0
.db "into wall)",0
jp rnd
atk4:
.db "(bitchslaps",0
.db "user)",0
jp rnd
atk5:
.db "(punches user)",0
jp rnd
atk6:
.db "(shoots user",0
.db "in the head)",0
jp rnd
atk7:
.db "(spits acid on",0
.db "user)",0
jp rnd
atk8:
.db "(cuts user)",0
jp rnd
atk9:
.db "(slices user)",0
jp rnd
atk10:
.db "(bites user)",0
jp rnd
atk11:
.db "(impales user)",0
jp rnd
atk12:
.db "(cuts user's",0
.db "throat)",0
jp rnd
atk13:
.db "(zaps user with",0
.db "laser eyes)",0
jp rnd
atk14:
.db "(uses",0
.db "head explody on",0
.db "user)",0
jp rnd
atk15:
.db "(tortures user)",0
jp rnd
atk16:
.db "fires a rocket",0
.db "at user)",0
jp rnd
END
.end
Truly great madness cannot be achieved without significant intelligence.
http://www.xanga.com/jakku_kun, rants by me.
http://www.xanga.com/jakku_kun, rants by me.