1; 2; 3 4 SECTION code_clib 5 PUBLIC psg_init 6 PUBLIC _psg_init 7 8psg_init: 9_psg_init: 10 11 ld e,@01010101 12 xor a ; R0: Channel A frequency low bits 13 call outpsg 14 15 ld e,a 16 17 ld d,12 18psg_iniloop: 19 inc a ; R1-13: set all to 0 but 7 and 11 20 cp 7 21 jr z,skip 22 ;cp 11 23 ;jr z,skip 24 call outpsg 25skip: 26 dec d 27 jr nz,psg_iniloop 28 29 ld e,@11111000 ; R7: Channel setting. Enable sound channels ABC and input on ports A and B 30 ld a,7 31 call outpsg 32 33 ld e,@00001011 ; R11: Envelope 34 ld a,11 35 36outpsg: 37 ld bc,18 38 OUT (C),A 39 ld a,e 40 inc bc 41 OUT (C),A 42 ret 43 44