▶️ ЗАБЕРИ СВОИ 8 ПОДАРКОВ 🎁 ПРИ СОЗДАНИИ СВОЕГО МАЙНКРАФТ СЕРВЕРА
Датапаки/IBIS - Peripherals Addon

IBIS - Peripherals Addon

Peripheral Addon for IBIS

2
0

This is an addon to the IBIS datapack to add a peripheral api support, which includes enabling in and out instructions.

By default there are two integrated peripheral types: debug and rawlog (more can be added via other datapacks). Only debug is a peripheral for testing, so this will focus on the rawlog peripheral only.

The rawlog peripheral displays data using /tellraw, but flushes only on \n.

Like usual you'll have to create a CPU, but now you can also add a peripheral to the CPU:

  • function ibis:create_cpu (result is cpu id)
  • function ibis:switch_context {cpu_id:<cpu_id>}
  • function ibis.peripheral.rawlog:instantiate (result is the instance id of the peripheral)
  • function ibis.peripheral:instance/link {cpu_id:<cpu_id>,instance_id:<instance_id>} this links the created peripheral to the cpu
  • data modify storage ibis:mem_<cpu_id> roms set value [{base:0x0000,bytes:[B;0xeb,0xbb,0xbb,0xec,0x48,0x65,0x0e,0x10,0xec,0x6c,0x6c,0x0e,0x10,0xec,0x6f,0x2c,0x0e,0x10,0xec,0x20,0x77,0x0e,0x10,0xec,0x6f,0x72,0x0e,0x10,0xec,0x6c,0x64,0x0e,0x10,0xec,0x21,0x0a,0x0e,0x10,0xec,0x80,0x00,0x1f,0xd1]}] (this is a "Hello, world!" ROM, code below)
  • function ibis:emu/reset

You might have to step the cpu a couple times for the message to display.

Hello world code
mov r0, 0xbbbb ; assign r0 to default port used for rawlog
; now write "Hello, world!\n" and send to rawlog (48 65 6C 6C 6F 2C 20 77 6F 72 6C 64 21 0A in hex)
mov r1, 0x4865 ; characters 'He'
out word r1, r0 ; send r1 to r0
mov r1, 0x6c6c ; characters 'll'
out word r1, r0 ; send r1 to r0
mov r1, 0x6f2c ; characters 'o,'
out word r1, r0 ; send r1 to r0
mov r1, 0x2077 ; characters ' w'
out word r1, r0 ; send r1 to r0
mov r1, 0x6f72 ; characters 'or'
out word r1, r0 ; send r1 to r0
mov r1, 0x6c64 ; characters 'ld'
out word r1, r0 ; send r1 to r0
mov r1, 0x210a ; characters '!\n'
out word r1, r0 ; send r1 to r0

mov r1, 0x8000 ; set r1 to the value of the STOP flag
or r13, r1 ; set STOP flag in flag register

If you want to destroy the peripheral, do function ibis.peripheral:instance/destroy {instance_id:<instance id>}, not any of the functions from other namespaces, because this one actually handles proper deleting of the data, which later calls the correct destroy of the instance.

You can also unlink the peripheral from a cpu using function ibis.peripheral:instance/unlink {instance_id:<instance id>} (or you can link it to another cpu, which will unlink from the previous cpu)

Совместимость

Minecraft: Java Edition

26.1.x

Платформы

Поддерживаемые окружения

Клиент и сервер

Детали

Лицензия:LicenseRef-All-Rights-Reserved
Опубликован:1 месяц назад
Обновлён:1 месяц назад
Главная