ringdata: MACRO
	db \1 ; Ring received
	bigdw \2 ; Ash needed
	db \3 ; Level required
	db \4 ; Stone needed
	db \5 ; Stone quantities
	ENDM

JewelingScript::
	opentext
	writetext Jeweling_WelcomeText
	loadscrollingmenudata RingMenu
.jewelingLoop
	scrollingmenu %10
	sif false, then
		closewindow
		jumptext Jewling_WeHopeToSeeYouSoon
	sendif

	addvar -1
	loadarray RingTable
	readarray 3
	comparevartobyte wJewelingLevel
	sif false, then
		readarray 3
		writetext LowLevelText
	selse
		readarrayhalfword 1
		callasmf CheckAsh
		sif =, 2, then
			writetext NotEnoughAshText
		selse
			cmdwitharrayargs
			db takeitem_command, %11, 4, 5
			endcmdwitharrayargs
			sif false, then
				readarray 4
				itemtotext 0, 0
				readarray 5
				itemplural 0
				writetext NotEnoughStonesText
			selse
				readarray 0
				verbosegiveitem ITEM_FROM_MEM, 1
				waitbutton
				sif false, then
					cmdwitharrayargs
					db giveitem_command, %11, 4, 5
					endcmdwitharrayargs
				selse
					readarrayhalfword 1
					callasm TakeAsh
					readarrayhalfword 1
					copybytetovar wScriptArrayCurrentEntry
					divideop 0, 2
					addvar 1
					givecraftingEXP CRAFT_JEWELING
				sendif
			sendif
		sendif
	sendif
	jump .jewelingLoop

Jewling_WeHopeToSeeYouSoon:
	db TX_COMPRESSED, $6d, $0b, $e7, $37, $9d, $19, $22, $02, $12, $71
	db $a6, $80

NotEnoughStonesText:
	db TX_COMPRESSED, $72, $85, $a8, $43, $3c, $c7, $30
	deciram hScriptVar, 1, 2
	db TX_COMPRESSED
	db $78, $1c
	db $85, $56, $18, $fe, $a9, $1c, $b4, $8d, $11, $63, $27, $3e
	db $07, $30

LowLevelText:
	db TX_COMPRESSED, $72, $85, $a8, $fb, $48, $b8, $ac, $e7, $4c, $18
	db $fa, $f3, $98, $00
	deciram hScriptVar, 1, 2
	db TX_COMPRESSED, $83, $24, $0a, $f2, $6b, $96
	db $15, $4f, $ea, $91, $cb, $48, $d1, $16, $32, $73
	db $e0, $73

NotEnoughAshText:
	db TX_COMPRESSED, $72, $85, $a8, $43, $3c, $c7, $30
	deciram hScriptHalfwordVar, 2, 4
	db TX_COMPRESSED, $9c, $af, $5f
	db $43, $c1, $c2, $6a, $13, $2c, $31, $fd, $52
	db $35, $56, $91, $a2, $2c, $64, $e7
	db $c0, $e6

Jeweling_WelcomeText:
	db TX_COMPRESSED, $6e, $7d, $64, $2f, $9f, $e5, $47, $d6, $42, $f9, $f1

	db $00, $ea, $33, $a4, $8f, $ea, $91, $cd, $8b, $19, $39
	db $7b, $00, $ae, $02, $0b, $5f, $83, $c2, $02, $0b

	db $40, $13, $a0, $c7, $2d, $27, $08, $6c, $9a, $11, $ab
	db $04, $f3, $fb, $66, $b1, $ef, $51

	db $e0, $0d, $d2, $36, $53, $16, $32, $73, $32, $18, $08, $2d
	db $3d, $56, $92, $e5, $86, $3f, $aa, $47
	db $4b, $4f, $10

RingMenu:
	db %1000010
	db 02, 01
	db 10, 15
	dw .MenuData2
	db 1

.MenuData2
	db %100000
	db 4, SCREEN_WIDTH + 5
	db RingTableEntrySizeEnd - RingTable
	dba RingTable_WithListQuantity
	dba PlaceMenuItemName
	dba PlaceMenuItemRingCost
	dba UpdateItemDescription

PlaceMenuItemRingCost:
	push de
	callba ScrollingMenu_GetAddressOfMenu_UseScrollingMenuCursorPosition
	inc hl
	ld a, [hli]
	ld b, [hl]
	ld c, a
	ld hl, sp + 0
	ld d, h
	ld e, l
	pop hl
	push bc
	lb bc, 2, 4
	call PrintNum
	pop bc
	ld a, " "
	ld [hli], a
	ld a, "g"
	ld [hli], a
	ld [hl], "."
	ret

RingTable_WithListQuantity:
	db 8
RingTable:
	ringdata GRASS_RING, 25, 0, LEAF_STONE, 1
RingTableEntrySizeEnd:
	ringdata FIRE_RING, 25, 4, FIRE_STONE, 1
	ringdata WATER_RING, 50, 8, WATER_STONE, 1
	ringdata THUNDER_RING, 50, 12, THUNDERSTONE, 2
	ringdata SHINY_RING, 75, 17, SHINY_STONE, 3
	ringdata DAWN_RING, 75, 21, DAWN_STONE, 3
	ringdata DUSK_RING, 100, 25, DUSK_STONE, 3
	ringdata MOON_RING, 100, 29, MOON_STONE, 3
RingTableEnd:
	db $ff
