From: cuz Date: Tue, 5 Nov 2002 10:48:20 +0000 (+0000) Subject: New randomize() function for nearly all platforms X-Git-Tag: V2.12.0~2145 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3fae969b5b5372d8b60a7d0022c5ae75615361c6;p=cc65 New randomize() function for nearly all platforms git-svn-id: svn://svn.cc65.org/cc65/trunk@1487 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/c128/Makefile b/libsrc/c128/Makefile index 4096855b5..bbf6e953a 100644 --- a/libsrc/c128/Makefile +++ b/libsrc/c128/Makefile @@ -21,6 +21,7 @@ OBJS = _scrsize.o \ cputc.o \ kbhit.o \ mouse.o \ + randomize.o \ readjoy.o \ rs232.o \ tgi_mode_table.o\ diff --git a/libsrc/c128/c128.inc b/libsrc/c128/c128.inc index 8e4415e70..87d88f19e 100644 --- a/libsrc/c128/c128.inc +++ b/libsrc/c128/c128.inc @@ -8,6 +8,7 @@ ST = $90 ; IEC status byte +TIME = $A0 ; 60HZ clock FNAM_LEN = $B7 ; Length of filename SECADR = $B9 ; Secondary address DEVNUM = $BA ; Device number diff --git a/libsrc/c128/randomize.s b/libsrc/c128/randomize.s new file mode 100644 index 000000000..e4b731edd --- /dev/null +++ b/libsrc/c128/randomize.s @@ -0,0 +1,17 @@ +; +; Ullrich von Bassewitz, 05.11.2002 +; +; void randomize (void); +; /* Initialize the random number generator */ +; + + .export _randomize + .import _srand + + .include "c128.inc" + +_randomize: + ldx VIC_HLINE ; Use VIC rasterline as high byte + lda TIME ; Use 60HZ clock as low byte + jmp _srand ; Initialize generator + diff --git a/libsrc/c64/Makefile b/libsrc/c64/Makefile index 636f7abfd..f35520ecf 100644 --- a/libsrc/c64/Makefile +++ b/libsrc/c64/Makefile @@ -24,6 +24,7 @@ OBJS = _scrsize.o \ cputc.o \ kbhit.o \ mouse.o \ + randomize.o \ readjoy.o \ rs232.o \ tgi_mode_table.o \ @@ -43,4 +44,4 @@ all: $(OBJS) $(TGIS) clean: @rm -f $(OBJS) $(TGIS:.tgi=.o) - + diff --git a/libsrc/c64/c64.inc b/libsrc/c64/c64.inc index 315aaf698..0d6b1c821 100644 --- a/libsrc/c64/c64.inc +++ b/libsrc/c64/c64.inc @@ -8,6 +8,7 @@ ST = $90 ; IEC status byte +TIME = $A0 ; 60 HZ clock FNAM_LEN = $B7 ; Length of filename SECADR = $B9 ; Secondary address DEVNUM = $BA ; Device number diff --git a/libsrc/c64/randomize.s b/libsrc/c64/randomize.s new file mode 100644 index 000000000..c46764b60 --- /dev/null +++ b/libsrc/c64/randomize.s @@ -0,0 +1,17 @@ +; +; Ullrich von Bassewitz, 05.11.2002 +; +; void randomize (void); +; /* Initialize the random number generator */ +; + + .export _randomize + .import _srand + + .include "c64.inc" + +_randomize: + ldx VIC_HLINE ; Use VIC rasterline as high byte + lda TIME ; Use 60HZ clock as low byte + jmp _srand ; Initialize generator + diff --git a/libsrc/cbm510/Makefile b/libsrc/cbm510/Makefile index 729e9bce4..e7e1b8494 100644 --- a/libsrc/cbm510/Makefile +++ b/libsrc/cbm510/Makefile @@ -28,6 +28,7 @@ OBJS = _scrsize.o \ mouse.o \ peeksys.o \ pokesys.o \ + randomize.o \ readjoy.o \ rs232.o \ tgi_mode_table.o diff --git a/libsrc/cbm510/randomize.s b/libsrc/cbm510/randomize.s new file mode 100644 index 000000000..f32bb3701 --- /dev/null +++ b/libsrc/cbm510/randomize.s @@ -0,0 +1,16 @@ +; +; Ullrich von Bassewitz, 05.11.2002 +; +; void randomize (void); +; /* Initialize the random number generator */ +; + + .export _randomize + .import _srand + .importzp time + +_randomize: + ldx time ; Use 50/60HZ clock + lda time+1 + jmp _srand ; Initialize generator + diff --git a/libsrc/cbm610/Makefile b/libsrc/cbm610/Makefile index d6575c5ef..4967dd7bb 100644 --- a/libsrc/cbm610/Makefile +++ b/libsrc/cbm610/Makefile @@ -27,6 +27,7 @@ OBJS = _scrsize.o \ kudtim.o \ peeksys.o \ pokesys.o \ + randomize.o \ rs232.o all: $(OBJS) diff --git a/libsrc/cbm610/randomize.s b/libsrc/cbm610/randomize.s new file mode 100644 index 000000000..f32bb3701 --- /dev/null +++ b/libsrc/cbm610/randomize.s @@ -0,0 +1,16 @@ +; +; Ullrich von Bassewitz, 05.11.2002 +; +; void randomize (void); +; /* Initialize the random number generator */ +; + + .export _randomize + .import _srand + .importzp time + +_randomize: + ldx time ; Use 50/60HZ clock + lda time+1 + jmp _srand ; Initialize generator + diff --git a/libsrc/pet/Makefile b/libsrc/pet/Makefile index 49a578629..4bc6c2212 100644 --- a/libsrc/pet/Makefile +++ b/libsrc/pet/Makefile @@ -19,7 +19,8 @@ OBJS = _scrsize.o \ conio.o \ cputc.o \ crt0.o \ - kbhit.o + kbhit.o \ + randomize.o all: $(OBJS) diff --git a/libsrc/pet/pet.inc b/libsrc/pet/pet.inc index 4dcb73947..e83051222 100644 --- a/libsrc/pet/pet.inc +++ b/libsrc/pet/pet.inc @@ -6,6 +6,7 @@ ; --------------------------------------------------------------------------- ; Zero page, Commodore stuff +TIME = $8D ; 60HZ clock MEMSIZE = $34 ; Size of memory installed ST = $96 ; IEC status byte SECADR = $D3 ; Secondary address diff --git a/libsrc/pet/randomize.s b/libsrc/pet/randomize.s new file mode 100644 index 000000000..aea26df04 --- /dev/null +++ b/libsrc/pet/randomize.s @@ -0,0 +1,17 @@ +; +; Ullrich von Bassewitz, 05.11.2002 +; +; void randomize (void); +; /* Initialize the random number generator */ +; + + .export _randomize + .import _srand + + .include "pet.inc" + +_randomize: + ldx TIME + lda TIME+1 ; Use 60HZ clock + jmp _srand ; Initialize generator + diff --git a/libsrc/plus4/Makefile b/libsrc/plus4/Makefile index e7f620720..2c431741e 100644 --- a/libsrc/plus4/Makefile +++ b/libsrc/plus4/Makefile @@ -20,6 +20,7 @@ OBJS = _scrsize.o \ cputc.o \ crt0.o \ kbhit.o \ + randomize.o \ readjoy.o \ tgi_mode_table.o diff --git a/libsrc/plus4/plus4.inc b/libsrc/plus4/plus4.inc index 5b8ab265b..259fc7540 100644 --- a/libsrc/plus4/plus4.inc +++ b/libsrc/plus4/plus4.inc @@ -8,6 +8,7 @@ ST = $90 ; IEC status byte +TIME = $A3 ; 60HZ clock FNAM_LEN = $AB ; Length of filename SECADR = $AD ; Secondary address DEVNUM = $AE ; Device number diff --git a/libsrc/plus4/randomize.s b/libsrc/plus4/randomize.s new file mode 100644 index 000000000..aae7ef59e --- /dev/null +++ b/libsrc/plus4/randomize.s @@ -0,0 +1,17 @@ +; +; Ullrich von Bassewitz, 05.11.2002 +; +; void randomize (void); +; /* Initialize the random number generator */ +; + + .export _randomize + .import _srand + + .include "plus4.inc" + +_randomize: + ldx TED_VLINELO ; Use TED rasterline as high byte + lda TIME ; Use 60HZ clock as low byte + jmp _srand ; Initialize generator + diff --git a/libsrc/vic20/Makefile b/libsrc/vic20/Makefile index 30c868e88..49f975557 100644 --- a/libsrc/vic20/Makefile +++ b/libsrc/vic20/Makefile @@ -20,6 +20,7 @@ OBJS = _scrsize.o \ conio.o \ cputc.o \ kbhit.o \ + randomize.o \ readjoy.o \ write.o diff --git a/libsrc/vic20/randomize.s b/libsrc/vic20/randomize.s new file mode 100644 index 000000000..bbf9733df --- /dev/null +++ b/libsrc/vic20/randomize.s @@ -0,0 +1,21 @@ +; +; Ullrich von Bassewitz, 05.11.2002 +; +; void randomize (void); +; /* Initialize the random number generator */ +; + + .export _randomize + .import _srand + + .include "vic20.inc" + +_randomize: + lda VIC_LINES ; Get overflow bit + asl a ; Shift bit 7 into carry + lda VIC_HLINE ; Get bit 1-8 of rasterline + rol a ; Use bit 0-7 + tax ; Use VIC rasterline as high byte + lda TIME ; Use 60HZ clock as low byte + jmp _srand ; Initialize generator + diff --git a/libsrc/vic20/vic20.inc b/libsrc/vic20/vic20.inc index 56bf0ec14..c67be541e 100644 --- a/libsrc/vic20/vic20.inc +++ b/libsrc/vic20/vic20.inc @@ -8,6 +8,7 @@ ST = $90 ; IEC status byte +TIME = $A0 ; 60HZ clock FNAM_LEN = $B7 ; Length of filename SECADR = $B9 ; Secondary address DEVNUM = $BA ; Device number @@ -30,10 +31,10 @@ PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC ; Kernal routines ; Direct entries -CLRSCR = $E55F -KBDREAD = $E5CF +CLRSCR = $E55F +KBDREAD = $E5CF NAMED_OPEN = $F495 -NAMED_CLOSE = $F6DA +NAMED_CLOSE = $F6DA PLOTCHAR = $EAAA ; Char in A, color in X ; --------------------------------------------------------------------------- @@ -46,8 +47,10 @@ NMIVec = $0318 ; --------------------------------------------------------------------------- ; I/O: 6560 VIC -VIC = $9000 -VIC_COLOR = $900F +VIC = $9000 +VIC_LINES = $9003 ; Screen lines, bit 7 is bit 0 from VIC_HLINE +VIC_HLINE = $9004 ; Rasterline, bits 1-8 +VIC_COLOR = $900F ; Border and background color ; --------------------------------------------------------------------------- ; I/O: 6522 VIA1