-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcredit.s
70 lines (62 loc) · 1.91 KB
/
credit.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright (c) 2011 Emmanuel Vadot <elbarto@neogeodev.org>
* Copyright (c) 2011 Furrtek <furrtek@neogeodev.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
.include "defines.inc"
.global credit_check
.global credit_down
.global check_coin
/*! DEF check_coin
\brief Checks if coins have been deposited and increments credits if so
*/
check_coin:
move.b (REG_STATUS_A),d0 | save actual HW read
move.b (PREV_COIN),d1 | get previous
not.b d0 | invert HW read
move.b d0,(PREV_COIN) | set previous=actual
eor.b d0,d1 | keep difference
and.b d0,d1 | keep only rising edge
andi.w #0x3, d1
btst.b #0,d1 | Coin 1
beq 1f
move.b (SRAM_COIN1), d0
abcd d1, d0
move.b d0, (SRAM_COIN1)
jsr (COIN_SOUND)
1:
btst.b #1, d1 | Coin 2
beq 1f
moveq #1, d1
move.b (SRAM_COIN1), d0
abcd d1, d0
move.b d0, (SRAM_COIN1)
jsr (COIN_SOUND)
1:
rts
credit_check:
tst.b (BIOS_MVS_FLAG)
beq 1f
move.b (REG_DIPSW), d0
and.b #0x40, d0
beq 1f
movea.l CREDIT_DEC_P1, a0
move.b (SRAM_COIN1), (CREDIT_DEC_P1)
move.b (SRAM_COIN2), (CREDIT_DEC_P2)
1:
rts
credit_down:
rts
.section .bss
PREV_COIN: .byte 0