RosettaCodeData/Task/Get-system-command-output/68000-Assembly/get-system-command-output-1.68000
2026-04-30 12:34:36 -04:00

21 lines
854 B
Text

doRNG:
;run this during vblank for best results.
JSR SYS_READ_CALENDAR
;gets the calendar.
;MAME uses your computer's time for this.
MOVE.L BIOS_HOUR,D0 ;D0 = HHMMSS00
LSR.L #8,D0 ;shift out the zeroes.
MOVE.L frame_timer,D1 ;this value is incremented by 1 every vBlank (i.e. just before this procedure is run)
NOT.L D1 ;flip all the bits of D1
MULS D1,D0
MULU D1,D0
MOVE.L JOYPAD1,D1 ;get the most recent button presses.
CloneByte D1 ;copy this byte to all 4 bytes of D1
EOR.L D1,D0
MOVE.L RNGout_32,D2 ;look at last time's results.
AND.B #1,D2 ;check if it's odd or even
BNE SwapRNGifEven
SWAP D0 ;if even, swap the low and high words of D0
SwapRNGifEven:
MOVE.L D0,RNGout_32
rts